Basic Linux Commands -GENERAL COMMANDS
We can see some general commands which should be useful for a new linux user.
jobs
βjobsβ it displays the works which are executed by the current terminal.
jobs -l
jobs -p
jobs -l ==> [1]+β3668β Stoppedβ man ls
Here,a work has been initiated (i.e man ls).This job was listed.
[1] ==> Job ID.
3668 ==> PID stands for Process ID.
Stopped ==> This work is currently stopped.
NOTE :
PID should be any digit,not only six digit.It could a single digit also.
fg %job_ID
bg %job_ID
Above commands represents foreground and background process.
fg %job_ID (i.e job_ID = 1).It execute the work in foreground.
bg %job_ID.It execute the work in background.
runlevel
sudo runlevel
Runlevels are predefined operating states or configurations that determine which processes and services are running.It range from 0 β 6.
0 ==> Halt or Shutdown the system.
1 ==> Single-user mode [ used for system maintenance or troubleshooting].
2 ==> Basic multi-user mode without networking.
3 ==> Full multi-user mode with networking.
4 ==> Not commonly used but can be customized for specific purposes.
5 ==> Full multi-user mode with networking and a graphical user interface.
6 ==> Reboot the system.
init 0 - 6
User can use any oneβof those range mentioned above using init command.
ps
βpsβ displays information about a selection of the active processes.
ps -x
ps -A
ps aux
ps -x ==> displays the information with PID and STAT.
ps -A ==> displays with PID only.
ps aux ==> displays every information.both user and root.
ps -ef
ps -ef | grep process_name
This shows the system process which is used widely.We can filter the process by using grep.
pstree
It displays the system process in a tree structure.
pstree -p username
-p ==> pass your username or root.
It displays the specific users tree structure.
kill -l
To kill a process we can use the command kill.
kill -l ==> It lists the KILL Commands.
kill -9 1527
kill -SIGKILL 1527
Letβs assume,a program (Gimp) got stuck while processing.We need to shutdown the program,but it canβt works on GUI.So we need to forcefully kill the process.For that,
we need to mention a kill command [ 9 ] to kill the process having a Process ID [ 1527 ] of Gimp.User can also use β-SIGKILLβ instead of β-9β.
NOTE :
If we didnβt mention kill number,it will take β15β by default which is a soft kill process.
We must enter the PID of that process not name.
killall gimp
Killall will kill the entire gimp program.
Here,we can use the name of the program.No need to use the PID.
top
top -u username
The top program provides a dynamic real-time view of a running system. It can display system summary
information as well as a list of processes or threads currently being managed by the Linux kernel. The
types of system summary information shown and the types, order and size of information displayed for
processes are all user configurable and that configuration can be made persistent across restarts.
top -u username ==> We can filter it with a specific user.
Thatβs itβ¦!