Linux commands – Basics

Linux servers are used in all the organizations and irrespective of your roles, likes/dislikes, you’d use Linux in one way or another.

So it’s good to learn the linux commands which would be handy for you whenever you get a chance to work on it.

I have listed the basic and commonly used commands in this post. I’ll continue to add more commands, detailed examples if required and will cover intermediate level commands as well. By practicing these, you can confidently add Linux in your skill sets.

Please feel free to comment on any commands you want to add, discuss.



Uptime command tells us about system running time (since last reboot), no. of users logged in and server load average.


2) Switch User

To switch to another user, use “su” command.

su user :Switch to another user in the same directory

‘su user -‘ : Switch to another user and load user’s home directory.

If you’re a normal user and have root access (sudo), then you can switch as root using “sudo su or sudo su – “ command.

It’s always recommended to use “su –“


3) Check OS

To check the OS and it’s version, you can use the below commands.



4) Directory:

To create a directory in your current location, use mkdir command.

You can also use absolute path (full path to the directory) if you’re in different location and wants dir to be created in different location.

i.e If you’re in / (root) directory, “mkdir hadoop” will create hadoop dir under /.

If you’re in /dev, then mkdir hadoop will create hadoop dir under /dev.

To create under /, use “mkdir /hadoop”


If you try to create subfolders, you’ll get an error if immediate parent doesn’t exist.

Here, cloud dir doesn’t exist under /hadoop, so /hadoop/cloud/folder can’t be created.

To overcome that, you can pass “-p” option to mkdir command.

This will create all the directories mentioned if they don’t exist.


5) Directory Navigation

Navigation: cd is the command helps to navigate between directories.

Assume you’re in /tmp/fol1 directory and to go to, /home/hadoop

# cd /home/hadoop

To go back to “/tmp/fol1”, you can either use

# cd /tmp/fol1


# cd –

‘cd –‘ will take you to directory where you previously were before navigating to current directory.

To go one level back:

# cd ..


6) Files

There are handful of utilities available to create files in linux.


Cat command is commonly used to read files, but it can also be used to create file.

If you use cat command to read a file that doesn’t exist, it’ll throw an error as below.

To create a file, use “cat > filename”. You can type the contents in the shell and once you’re done, press Ctrl + C. Now “cat filename” will read and print the file contents.

To append to the file, use “cat >> filename”.

Note: Cat command is least used to create files but mainly used to read files.

Touch: Touch is used to create empty/0 byte files.

Simply type “touch filename”, it will create a 0 byte file with no contents.

You can add contents to the file using “vi” or echo or “cat”

Echo: As the name stands, it echoes whatever you type in the shell.

With echo you can create a file by using redirection operators. (> and >>)

echo “hello” > filename : creates a file with content “hello”

echo “bye” >> filename: appends the file with content “bye”

VI – Vi is the different beast altogether when it comes to editing/creating files and it can’t be covered in few examples.


7) Copy/Move

cp command is used to copy files/folders to same location or diff location.

mv command is used not only to move files/folders and also to rename the file by moving it to the same location.




I’ll add detailed examples on use cases of cp/mv command which are used a lot.


To be updated …



3 thoughts on “Linux commands – Basics

Leave a Reply

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