Basic linux commands for beginners

Here I am listing very basic UNIX commands to help out beginners. To open terminal, you can use keyboard shortcut ctrl+alt+t

Working Directory

whoami: display logged in user id

pwd: display present working directory

cd: change working directory
syntax: cd <Destination Directory Path>
Destination directory path can be absolute path or relative path to PWD
Example: if you are in a sub-directory and want to move one step up, you can use
cd ../

to move two directory upwards, you can use
cd ../../

and so on. If you want to go to root directory no matters which is your present working directory(PWD), you can use
cd ~

Here defines the root directory.

List Content

ls: list content in current directory
To list content of another directory, you can use
ls <directory path>

Create Directory

create directory in working directory
mkdir <directory Name>

Create directory in a path
mkdir <directoryPath/directoryName>

Example: mkdir /home/Desktop/test-directory

Create directory and sub-directory in one command
mkdir -p example/example2/example3
this will create example directory in working directory and nested sub-directories inside example directory

Delete directory

If you want to delete an empty directory, you can use rmdir command:
rmdir <directory Name>

To delete a directory with content, use rm command
rm -r <directory Name>
Here -r option is used to remove directories and their contents recursively.

Create File

If you want to create a file in current directory, you can use touch command:

touch <file Name>
Example: touch file.txt

View content of file

cat <fileName>
Example: cat file.txt

Copy file

To copy a file to a destination with same file name, you can use following syntax:
cp <Source File> <DestinationPath>
Example: cp file.txt /home/Desktop

To copy file with a different name, you can provide new-file-name with destination path.
Example: cp file.txt /home/Desktop/new-file-name.txt

Move file

Its just like cut-and-paste action. To move a file to a different location, you can use:
mv <source File> <destinationPath>

Example: mv file.txt /home/Desktop

Disk usage

To display disk usage of current directory, you can use du command.
when run du command, you will see space occupied by every file. To get total disk usage in one line, you can use -s option here -s stands for summary. This will show total size in KBs.
du -s
Output: 257404 .

To make it more readable format, you can use -h (human readable) option.
du - sh

Output: 252M .

If you want to check disk usage by a directory, you can specify directory path with du command.
du -sh ~/Downloads/

Output: 17G /home/user/Downloads/

Shutdown system

init 0

Restart System

init 6

Command description

whatis: display one-line manual page descriptions
syntax: whatis <command>

whatis ls

man: It shows detailed description or we can say manual page for any command
syntax: man <command Name>
man ls


cal: displays a calendar and the date of Easter


Show calendar for specific month and year: cal Month Year

cal 10 2020

System IP

To display system’s ip, you can use ifconfig command.

Please follow and like us:

Leave a Reply

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

Back to Top