All UNIX Commands, Most Frequently Used, Basics and Advanced in One Place

Hi Folks,

Now, I come up with topic called ‘All Unix Commands (Basics and Advanced) in One Place. Here, I’ve tried to give all UNIX Commands and it’s description in one place. Note that you may not find them on all UNIX machines and some of these commands are different on non-Solaris machines. This is not just like other post. It helps all UNIX users always. Book mark it for your feature reference.

Some of these UNIX commands have links for detailed view and examples. In future I’ll try to give detailed view and examples for all commands.

If you want to see manual for each command, use man command with valid parameters or qualifiers which should be valid commands as a qualifier. It will give manual page for given command.

$ man command

Use –help after each command, it will give some tips on given command.

$ command --help

Let’s start with most frequently used UNIX commands, I’ll give examples from my Ubuntu machine for all these UNIX commands.

Most Frequently Used Commands with Examples

cd – Change the directory from present directory

Command cd
Syntax cd [directory]
Description Change the directory from present directory.

 

Examples:

stephen@stephen:~$ cd /opt/
stephen@stephen:/opt$

The above command and directory would go into opt directory.

stephen@stephen:/opt$ cd ../usr/bin/
stephen@stephen:/usr/bin$

The above command and directory path would go back one level from current (opt) directory and would go into usr/bin directory.

stephen@stephen:/usr/bin$ cd ../../opt/workspace/
stephen@stephen:/opt/workspace$

The above command and directory path would go back two levels from current (/usr/bin) directory and would go into /opt/workspace directory.

stephen@stephen:/opt/workspace$ cd
stephen@stephen:~$

Finally, the above cd command with out any directory path go into home directory which is a by default working directory.

pwd – Print the full file name of the current working directory

Command pwd
Syntax pwd [OPTION]
Description Print the full file name of the current working directory.

 

Example:

stephen@stephen:~$ pwd
/home/stephen

The above command would give full name of the current working directory.

ls – List information about the files (the current directory by default) [More…]

Command ls
Syntax ls [OPTION]  [FILE]
Description List information about the files (the current directory by default).

 

Examples:

stephen@stephen:~$ cd demo_ls/
stephen@stephen:~/demo_ls$ ls
DSC02335.JPG  OpenSSL.tar.gz  output.pdf  python_exe.py  readme.txt  socket.py

The above ls command example list all the files in the current directory.

stephen@stephen:~/demo_ls$ ls -1
DSC02335.JPG
OpenSSL.tar.gz
output.pdf
python_exe.py
readme.txt
socket.py

The above ls command with qualifier -1 would listing all files one by one.

stephen@stephen:~/demo_ls$ ls -l
total 4624
-rw-r--r-- 1 stephen stephen 4573416 Dec 24 11:35 DSC02335.JPG
-rw-rw-r-- 1 stephen stephen   42107 Aug 19 17:06 OpenSSL.tar.gz
-rw-r--r-- 1 stephen stephen   82330 Nov  4 12:54 output.pdf
-rw------- 1 stephen stephen     110 Aug 13 16:42 python_exe.py
-rw-rw-r-- 1 stephen stephen       0 Jun 13  2013 readme.txt
-rw------- 1 stephen stephen   21058 Sep 24 11:29 socket.py

The above ls command with qualifier -l would listing all files with long listing format. For more practical examples see…

grep – Search for PATTERN in each FILE or standard input

Command grep
Syntax grep [OPTION]… PATTERN [FILE]…
Description Search for PATTERN in each FILE or standard input. PATTERN is, by default, a basic regular expression (BRE).

 

Examples:

stephen@stephen:~/demo_grep$ grep 'and' demo_file_1.txt 
This handout will help you understand how paragraphs are formed, how to develop stronger paragraphs, and how to completely and clearly express your ideas.
stephen@stephen:~/demo_grep$ grep 'And' demo_file_1.txt 
stephen@stephen:~/demo_grep$

The above grep command would highlight matching string in the file. It is case sensitive.

stephen@stephen:~/demo_grep$ grep -i 'and' demo_file.txt
This handout will help you understand how paragraphs are formed, how to develop stronger paragraphs, and how to completely and clearly express your ideas.

The above grep -i command would highlight matching string for given string in a file.  indicates case insensitive.

stephen@stephen:~/demo_grep$ grep -i 'and' *
demo_file_1.txt:This handout will help you understand how paragraphs are formed, how to develop stronger paragraphs, and how to completely and clearly express your ideas.
demo_file_2.txt:This handout will help you understand how paragraphs are formed, how to develop stronger paragraphs, and how to completely and clearly express your ideas.
demo_file_3.txt:This handout will help you understand how paragraphs are formed, how to develop stronger paragraphs, and how to completely and clearly express your ideas.

The above grep -i command would highlight matching string for given string in all files. indicates all files recursively.

who – Print information about users who are currently logged in [More…]

Command who
Syntax who [OPTION]… [ FILE | ARG1 ARG2 ]
Description Print information about users who are currently logged in.

 

Examples:

stephen@stephen:~$ who
stephen  tty7         2013-12-23 10:22 (:0)
stephen  pts/0        2013-12-23 10:54 (:0)
stephen  pts/11       2013-12-23 14:09 (:0)
stephen  pts/12       2013-12-23 15:22 (:0)

The above who command would list currently logged-in users.

stephen@stephen:~$ who -b
         system boot  2013-12-23 10:21

The above who -b command would list last system boot time.

stephen@stephen:~$ who -H
NAME     LINE         TIME             COMMENT
stephen  tty7         2013-12-23 10:22 (:0)
stephen  pts/0        2013-12-23 10:54 (:0)
stephen  pts/2        2013-12-23 12:43 (:0)
stephen  pts/11       2013-12-23 14:09 (:0)
stephen  pts/12       2013-12-23 15:22 (:0)

The above who -H command would list logged-in user information on top of it there are headers for each column.

 


Django-Python Web based application developer.

Share This Post

Related Articles

Leave a Reply

© 2017 Techy Diary. All rights reserved.
Powered by Charvi Groups