Useful Linux Commands


1. Uptime Command
In Linux uptime command shows since how long your system is running and the number of users are currently logged in and also displays load average for 1,5 and 15 minutes intervals.

2. W Command
It will display users currently logged in and their process along-with shows load averages. also shows the login nametty nameremote hostlogin timeidle timeJCPUPCPU, command and processes.

Available options

  •   -h : displays no header entries.
  •   -s : without JCPU and PCPU.
  •   -f : Removes from field.
  •   -V : (upper letter) – Shows versions.

3. Users Command
Users command displays currently logged in users. This command don’t have other parameters other than help and version.
4. Who Command
who command simply return user namedatetime and host information. who command is similar to wcommand. Unlike w command who doesn’t print what users are doing. Lets illustrate and see the different between who and w commands.
Who command Options

  •   -b : Displays last system reboot date and time.
  •   -r : Shows current runlet.
  •   -a, –all : Displays all information in cumulatively.

5. Whoami Command
whoami command print the name of current user. You can also use “who am i” command to display the current user. If you are logged in as a root using sudo command “whoami” command return root as current user. Use “who am i” command if you want to know the exact user logged in.
6. ls Command
ls command display list of files in human readable format.
Sort file as per last modified time using ls -ltr
8. Less Command
less command allows quickly view file. You can page up and down. Press ‘q‘ to quit from less window.
Eg: less sample.txt

9. More Command
more command allows quickly view file and shows details in percentage. You can page up and down. Press ‘q‘ to quit out from more window.
Eg: more sample.txt
10. Cat Command
cat command used to view multiple file at the same time.
Eg: cat file1 file2
11. pwd command (print working directory)
pwd command return with present working directory.

12. Free command
Free command shows freetotal and swap memory information in bytes.
Free with -t options shows total memory used and available to use in bytes.
13. Top Command
top command displays processor activity of your system and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being used. Use top command with ‘u‘ option this will display specific User process details as shown below. Press ‘O‘ (uppercase letter) to sort as per desired by you. Press ‘q‘ to quit from top screen.

22. Tar Command
tar command is used to compress files and folders in Linux. For example the below command will create a archive for /home directory with file name as archive-name.tar.
tar –cvf archive-name.tar /home

To extract tar archive file use the option as follows
tar –xvf archive-name.tar

23. Grep Command
grep search for a given string in a file. Only tecmint user displays from /etc/passwd file. we can use -i option for ignoring case sensitive.
grep ‘nametofind’ /etc/passwd
24. Find Command
Find command used to search filesstrings and directories. The below example of find command searchtecmint word in ‘/‘ partition and return the output.
find /pathtosearch –name filename or strings or directories
.
25. lsof Command
lsof mean List of all open files. Below lsof command list of all opened files by user tecmint.

26. ps command
ps command displays about processes running in the system. Below example show init process only.
Ps –ef | grep init

28. kill command
Use kill command to terminate process. First find process id with ps command as shown below and kill process with kill -9 command.
Kill -9 8765

29. rm command
rm command used to remove or delete a file without prompting for confirmation.

Using -i option to get confirmation before removing it. Using options ‘-r‘ and ‘-f‘ will remove the file forcefully without confirmation.


Comments

Popular posts from this blog

How SQL Indexes Work internally ?

UML,HLD and LLD.

Mutable and Immutable Objects