Top Linux Commands for Administrator

1. less View file contents one page at a time.

less filename.txt

2. grep – Search text in files.

grep "pattern" file.txt
grep -r "error" /var/log    # Recursive search in /var/log

3. diff – Compare two files line by line.

diff file1 file2

4. cmp – Compare two files byte by byte.

cmp file1 file2

5. wc – Count lines, words, and characters in a file.

wc file.txt
wc -l file.txt

6. find – Search for files and directories.

find /home -name "file.txt"   
find /var -size +100M          

7. zip and gzip – Compress files

8. unzipand gunzip – Decompress files

9. tar – Archive files

10. who – Show logged-in users.

who

11. whoami – Display current user.

whoami

12. id – Show user ID (UID) and group ID (GID).

id

13. adduser – Add a new user.

sudo adduser username

14. passwd – Change user password.

passwd username

15. usermod – Modify user accounts.

sudo usermod -aG sudo username 

16. deluser – Delete a user.

sudo deluser username

17. groups – Display groups a user belongs to.

groups username

18. su – Switch user accounts.

su - username

19. sudo – Execute commands as another user.

sudo command

20. top – Display dynamic process information.

top

21. ps – Display running processes.

ps aux 

22. htop – Interactive process viewer (install required).

htop

23. kill – Terminate a process.

kill PID  

24. killall – Kill all processes by name.

killall processname

25. pkill – Kill processes by name or attribute.

pkill -u username 

26. bg – Resume a background process.

bg %1 

27. fg – Bring a background process to the foreground.

fg %1

28. nice and renice – Set process priority.

nice -n 10 command    
renice 5 PID 

29. apt-get Install, remove, and manage packages (Debian-based systems)

30. yum – Install, remove, and manage packages (RPM-based systems)

31. rpm – Manage RPM packages

32. apt-cache – Search package cache

33. apt-key – Manage apt keys

34. aptitute – Advanced package management tool

35. apt-get update Update package list

36. apt-get upgrade Upgrade installed packages

37. apt-get install Install packages

38. apt-get removeRemove packages

39. history – Display command history

40. man – Display manual pages

41. nohup Run command immune to hangups

42. screen – Create multiple terminal sessions

43. tmuxTerminal multiplexer

44. lsofList open files

45. straceTrace system calls

46. itraceTrace library calls

47. dd – Copy a file

48. fdisk – Disk partitioning tool.

49. parted – Disk partitioning tool.

50. time – Measure time taken by a command.

Leave a Comment