Basic Commands
  • Share this blog:

List of Basic Commands in Unix

#  --> root user prompt. $  -->  user working prompt. $ log name  --> displays current user name. $ pwd  -->  present working directory. $ date  -->  Display current date & time. $cal  -->  Displays current month calendar. $cal 2020  --> particular year total months. $cal 04 2020  -->  2020 year 04th month calendar. $who  -->  To display the information about all the users who have logged into the system. $ who am i  -->  It displays current user name. $ finger  -->  It displays complete information about all the users who are logged in. $ uptime  -->  How log server up & running, how many users connected and load avg time.   $ which (Or)  $ wher    -->    Given command location EX: Which date   $tty    -->     Terminal position. $df      -->    Displays disk free size $du      -->    Disk usage information $clear    -->     To clear the screen   Creating files:

  • Cat (concatenate): It is used to create a file and display, appending the contents of a file
  • To create a file:

$Cat>filename Hello world Ctrl+D (To save the file)

  • To Display the content of the files:

$cat<filename (or) $cat filename  

  • To append the data in the existing file:

$cat >>filename ------------------------- ------------------------- Ctrl +D (To save)  

  • Touch: To create multiple files but all are empty.

Syn:  $touch file1 file2 file3 ……………..filen                Ex: $touch file1 file2 file3

  • Ls: Displays the contents of a directory.

  Options: -    r    -->Reverse -   i    -->inode  -a  --> hidden  -   l  --> long list -R    -->Recursively -   h  --> human readable   Mkdr: Creates a directory. Syn:  mkdir <Dirname> $mkdir linux

  • To create multiple directories:

$ mkdir dir1 dir2 dir3 -----------------dirn

  • To create a nested directory:

$ mkdir –P world/asia/india/ap/hyd Parent

  • To check: $ tree world

(or) $   ls – R

  • Navigation commands:

Cd:  Changes the current location. Cd.. --->To go one level back cd../.. ---> To go two levels back cd --->To change user’s home directory. EX: $ cd world $ ls Note:  The trailing slash (1) is optional when you’re using the cd command. It indicates that the name being specified is a directory. EX:  $cd Documents/

  • CP: Copies files or directories form one location to another.

Syn: CP [options] source destination --- R   --->  copies recursively --- f     ---> Copies forcefully --- V  --->  provides verbose output   EX:       $ CP file1 file2   ------------>  one file to another. $CP file1 file2 Documents   ------------>   Multiple files into directory. $CP  -R Documents unix ------------>one directory to another. $ CP –rvf Documents unix world/asia/india/ap/hyd $ CP /var/log/messags ------------>  (.) represents current location.

Learn more about Linux Interview Questions in this blog post. 
Interested in mastering Linux ? Check out this blog post to learn more Linux Training
  • MV: Moves or renames files and directories.

Syn:   mv [options} SOURCE DEST --- V   --> verbose

  • Rename the file by specifying the file name & new name of the files

Mv messages messages.bak  

  • Move it to the test directory for safe keeping:

Mv messages. Bak test/ $ls test

  • Rm: Deletes files or directories

Syn:  rm [options} FILE ---    i  ---> interactive ---   r ---> Recursively ---   f  ---> Forcefully

  • Delete the messages.bak file:

$cd test $rm   - I  messages. Bak

  • Delete the test directory:

$ cd .. $ rm  - rf test/

  • File: Displays the type of a file

Syn:  file <file name> Ex:  $ file test1 Test1: empty $ file /etc/passwd Password : ASCII test. For indepth understanding of Linux click on

About Author
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated

Get stories of change makers and innovators from the startup ecosystem in your inbox