Common Linux Commands with Examples – Part 6

1. Objective

This Linux commands tutorial will provide you with Common Linux commands List that will help you in gaining further Linux programming knowledge. You will learn Linux commands like gunzip, bunzip2, tar, uniq, set, unset, uname, df, du and touch in this section. For more commands, go through Linux commands part 1, part 2, part 3, part 4 and part 5.

Common Linux Commands

2. Common Linux Commands

2.1. gunzip

a. Usage:

$ gunzip file.gz

This command unzips the zip file

2.2. bunzip2

a. Usage:

$ bunzip2 file.bz2

bun zip is used to again compress the already compressed file

b. Usage:

$ bunzip2 -d file.bz2

This command is used to decompress the file.

c. Usage:

$ zcat file.gz

This command is used to display the compressed zip file

2.3. tar

a. Usage:

$ tar -cvf dir.tar dir

tar rolls an entire directory into a single file. This command tar the dir into a tarboll called dir.tar, where -c is used to create an archive containing all specified items,-f is used for writing the archived item to spesified file,-v is used for verboed(description) the orignal directory will remain same.

b. Usage:

$ tar -xvf dir.tar

This command is used to untar the directory

2.4. uniq

a. Usage:

$ cat file.txt | uniq

This command will display the file which shows only unique entries .It display duplicate record only once.

b. Usage:

$ cat file.txt | uniq | sort

This command displays unique and sorted file

c. Usage:

$ cat file.txt | sort | uniq –d

This command displays non unique entries in sorted form

2.5. set

a. Usage:

$ set -o vi

This command is used to set various properties of your shell. It will use vi style key binding in the terminal.

b. Usage:

$ set -o emacs

This command uses emacs style key bindings in the terminal

c. Usage:

$ set –x

This command will activate debugging from here

d. Usage:

$ set +x

This command will deactivate debugging from here

2.6. unset

a. Usage:

$ TEST=asdf
$ echo $TEST
$ unset TEST
$ echo $TEST

This command is used to clear or unset the value of variable

2.7. uname

a. Usage:

$ uname

uname prints out various system information in the simplest form

b. Usage:

$ uname -a

If you use the -a flag for all, you get all sorts of information

2.8. df

a. Usage:

$ df -h

This command is used to see how much space you have left on your hard disk. The -h flag means “human readable,” form

2.9. du

a. Usage:

$ du -sh myfolder

This command is used for checking the sizes of individual directories

b. Usage:

$ cd
$ du -sh *

If you wanted to check how much space each folder is using in your HOME directory, you could do using this command

2.10. touch

a. Usage:

$ touch test

Touch makes an empty file. E.g., to make an empty file called test, use above command.


Leave a comment

Your email address will not be published. Required fields are marked *