Linux commands for beginners

Welcome to third part of linux commands tutorial. You will  have now practiced and enjoyed linux commands which we discussed in last two articles. This is the last part of Linux command series.  This does not mean we will not learn linux commands. We will be using new linux commands in our future articles.




As you guys know every moment happened in past make a history so, now we are going to start our class from  command history.

history command is used  to view the command line history.

Syntax history [option].
useful option are:

history –w file-name (save the history in text file),

history –c (clear the history).

There is lot of history in my command line that’s why I am using tail command to view

just last 10 command history with tail -10 option

historycmd
To save this history see screenshot. We are saving history to file historysave.txt

historycmd1
To clear history use history command with option(switch) -c

historycmd2




To view the currently running process use command ps.

ps stand for process status.

syntax ps [option] user-name.
useful options are:

ps –aux (view/show the all running system processes of given user),
ps –u user-name (view the current running process of given user).

pscmd

pscmd1

Also please try ps -ef 🙂 try yourself

If some process not running properly or there is any issue with process and  we want to terminate that process  we can use kill command to terminate the process. Normally it is used to kill a suspended or hanged process.

Syntax kill process-id.

to forcefully terminate a process) you can use kill -9 pid (process identification number)

[Note: you make sure that process is not related to system file it may be harmful for your system be aware with this command.]

Here I am going to kill firefox browser process which is highlighted in below image;

killcmd

Ok what if you are going to run a job/task that will take time and in mean time you want to work  or run another task . Well in that case append &(ampersand) to command. This will make job to run in background.

Alternatively if task is running  press ctrl+z this will put job in background in suspended state.

 

Syntax service-name/Command  & and ctrl+z.

backcmd

 

You can use bg to execute suspended jobs in background but to view all jobs in background use command jobs

 

bgcmd

Ok so we have put job in background and later at some point you want to  bring a background job to the foreground using fg command.

if you use fg command  without arguments, it will take the most recent background job to the foreground.

Syntax fg

fgcmd

Now we want to set or check date and time we can use the date command.

Syntax date [option].
There are so many useful options you can find in below image; (Note: you must be on root to change the time and date).

datecmd

If I want to search some string in a file(s) I can use command grep

This is  Very powerful command to  search/match pattern in file(s).
Syntax grep pattern file-name.
Useful options are grep –i (I option is used to ignore case sensitivity),
grep –color (highlight pattern)

grepcmd

Shutting down/power off system:

halt command which is used to shut down your system you can also use poweroff. If you want to restart your system then use reboot.

Syntax halt/poweroff/reboot.

haltcmd

I Hope you have enjoyed the tutorial please subscribe to our newsletter and it would be nice if you let us know your suggestions about article

 

SUBSCRIBE OUR NEWSLETTER
I agree to have my personal information transfered to MailChimp ( more information )
Join us by subscribing to our newsletter and learn IT subjects for free
We hate spam. Your email address will not be sold or shared with anyone else.