Most used and handy Linux commands (part_1)

Introduction

This article firstly was written for GeeksArticle website and published it there but after few days we decided to close the website and now I put it here. I hope that I complete it very soon.

This article is the first article of the most used and handy Linux commands series and in each article ten most useful and most used Linux commands are discussed. This article is dedicated to describe first ten most used and basic Linux shell commands with their useful switches. The commands which are going to be covered in this article arecd, ls, clear, pwd, date, sudo, su, login, reboot, halt. The commands are sorted base on their frequent in use, means that the most used one are described first and then the rest are explained. Before starting, it is good to know that each command has its own guide page which known as man page. So if you find that you need to know more about an especial command just type “man” before your command to access to full user-guide.

The following part expresses mentioned commands in details.

Most used and handy Linux commands (part_1)

cd

This command is one of the basic commands that everybody who wants to work in the text mode or simply with shell should know. The usage of cd is to change the path of the system. For example imagine that you are in your home directory and wants to change the path from home to your desktop easily you can do it with the use of cd. The overall usage of cd is written as below

cd directory name

Example

cd /home/kasra/Desktop

cd /

Cd accepts different arguments which give more flexibility to the user. The first thing which probably you want to do after learning and use it to go to a directory is how to back one directory back or one path back.cd ..is utilized to direct you to one path back exactly like Back button in GUI or window manager.

The second thing which is really useful is to back to your home directory without using too muchcd .. and just with one command. Using cd without any parameters do this for you. It redirects you to your home directory from any path easily.

ls

The usage oflscommand is exactly the same as olddircommand which is used in DOS and Windows command prompt. It shows the content of the directory. It task is the same as window manager which shows files and content of especial window in itself.

The first switch which is necessary to know is-a. This switch shows all contents mean it shows hidden files and folders.

Hint: In Unix like systems for hiding files or folders“.” sign is used in front of the name of the file or folder.

The second switch is-s. This switch is used to show the size of the listed files. The given size does not have any measurement quantity; therefore it is difficult to read. So the third switch is -hwhich is used with-scommand to show the size of the files in Kilobyte, Megabyte, Gigabyte, and so on.

Hint: Switches could be used together likels -ash.

clear

The usage of clearis really simple and robust. It is used to clear the screen and the equal command in DOS and Windows is cls.

pwd

If you do not know exactly which path you are at the moment you can usepwdcommand to tell you where you are at the moment.

date

Date command is used to get the current date and time of the system.

sudo

In Linux if you want to do some especial tasks or run especial commands (like mounting a file system) you need root (superuser) access to run them. Since in Linux using root user to login to the system is not recommended because the user has access to the system completely and one wrong command can damage to OS and causes failure in OS, therefore, on the necessity which you want to run some commands with root privilege you can usesudobefore the name of command. Firstly, it will ask for your password and then it runs the command. Bear in mind that sudocommand may not work on the all systems because the user is not eligible to use it and administrator limits the user.

su

Running this command gives access of root user to you. This command is locked by default in some Linux distributions like Ubuntu. If you sure and want to access to root user and it is locked then you can combine twosudoandsucommands together to pass the limitation of Ubuntu. As a result to access to root user you can use the below command

sudo su

login

This command is used to login to the system. It is useful especially when you are already login but meanwhile you want to login with the other user temporarily and keep your current session as well. For instance imagine that a system has two users’ accounts as “Jacob” and “Jacob_Work”. Now Jacob is already logged in but wants to access to Jacob_Work temporarily to do something. Therefore, login command can be used as followed

login Jacob_Work

reboot

Running this command causes system to be restarted. In some distributions normal (limited) user cannot run this command and need superuser access.

halt

This command causes system to be shutdown and such asrebootcommand in some distributions normal (limited) user cannot run this command and need superuser access.

References

An A-Z Index of the Bash command line for Linux. It consists all Linux commands with their switches

http://ss64.com/bash/

The Linux command line book written by William E. Shotts, Jr.This book is available for free in PDF format. Download from below link

http://sourceforge.net/projects/linuxcommand/files/TLCL/09.12/TLCL-09.12.pdf/download

Linux in a nutshell by Ellen Siever, Aaron Weber, Stephen Figgins, Robert Love, Arnold Robbins. Available at:

http://www.amazon.com/Linux-Nutshell-Ellen-Siever/dp/0596154488

Linux commands man pages.

send your idea and information to kasra.madadipouya@geeksweb.tk

Leave a Reply