Linux is a powerful and versatile operating system that is widely used for both personal and professional use. One of the key features that sets Linux apart from other operating systems is its command line interface. The command line, also known as the terminal, allows users to interact with the system directly and perform a wide variety of tasks.
To make the most of your Linux experience, it is essential to have a solid understanding of the command line and the various commands that are available. In this article, we will cover 40 essential Linux commands that every user should know. From navigating the file system to managing system processes and services, these commands will give you the foundational knowledge you need to effectively use your Linux system. Whether you are a beginner or an experienced user, this guide will provide you with the essential tools to work efficiently and effectively in the Linux command line.
1. ls - used to list the files and directories in a directory 2. cd - used to change the current directory 3. pwd - used to display the current working directory 4. mkdir - used to create a new directory 5. rmdir - used to remove an empty directory 6. rm - used to remove a file or directory 7. touch - used to create a new file 8. cp - used to copy a file or directory 9. mv - used to move or rename a file or directory 10. nano or vim - used to edit text files in the command line 11. cat - used to display the contents of a file 12. less - used to view the contents of a file one page at a time 13. grep - used to search for a specific string of text in a file or multiple files 14. find - used to search for files in a directory 15. chmod - used to change the permissions of a file or directory 16. chown - used to change the owner of a file or directory 17. su - used to switch to the superuser or root account 18. sudo - used to execute a command as the superuser or root account 19. exit - used to log out of the current user account 20. clear - used to clear the terminal screen 21. history - used to display a list of recently executed commands 22. top - used to display the currently running processes and their resource usage 23. ps - used to display the currently running processes 24. kill - used to terminate a running process 25. df - used to display the available and used disk space on a file system 26. du - used to display the size of a directory or file 27. free - used to display the amount of free and used memory in the system 28. ln - used to create a symbolic link between a file or directory 29. tar - used to create and extract archive files 30. gzip and gunzip - used to compress and decompress files 31. ssh - used to securely connect to a remote system 32. scp - used to securely copy files between systems 33. rsync - used to efficiently copy files and directories between systems 34. ping - used to test network connectivity 35. traceroute - used to display the route a packet takes to reach a host 36. netstat - used to display information about network connections and routing tables 37. ifconfig - used to configure network interfaces 38. apt-get - used to manage packages on Debian-based systems 39. yum - used to manage packages on Red Hat-based systems 40. systemctl - used to manage and view system services
These are some of the most commonly used Linux commands that every user should know. However, there are many more commands available, each with their own specific use cases. It is recommended that you continue to learn and explore new commands as you become more comfortable with the Linux command line.
Top comments (8)
rgis a good alternative for
grep. It provides better output, is very fast, and can easily search huge directories.
fdis a good alternative for
find. Easier to use and also very fast.
htopis a more user-friendly alternative to
top. There are also even better interfaces such as
ipcommand is the new alternative to the deprecated
aptshould be favored over
apt-get. The latter provides lower-level management of packages while
aptis intended to be more user-friendly.
aptshould be installed by default (apt only on Debian-based distros though). The other three are widely available for download in package managers such as apt.
i've used Linux for 20 years. Never heard of Ripgrep or Fd-find. I think the point here is to understand commands which are likely to be available, E.g. if you SSH to some random CentOS system. GNU CoreUtils type stuff.
They are relatively new tools that have gained popularity in maybe the past 5 years. I was suggesting them because they are much easier to use. I'm not dismissing find and grep, I still use them on remote systems as you say. But if I had a choice I would usually prefer fd and ripgrep.
Same with top. I don't willingly use it if I have htop available.
Have you ever had to rely upon an SSH connection to a bare bones Linux box for emergency surgery on Apache, or some such?
It's likely in that sort of a situation, you're not going to be able to install your favorite apps. I think that is the point of the O/P's article. It's why i bookmarked it, at least.
Indeed, I suppose there are certain things you just have to accept as "true". E.g. My private sites are hosted on a friends leased server he's had since the 1990's. It's solid, and I have SSH access. I tried to do something about Node.js or Laravel; NPM, Composer. I forget by now. But, even though I'm 100% trusted (and I think I was able to use sudo / apt... or Yum, i guess, etc.) I bailed on it because it just wasn't worth it. I probably could have installed the apps you mentioned, but that's at least a somewhat unique situation (permissions), and in the end, it just wasn't worth it to me to risk ANYTHING about his server.
Also. I hate VIM. I expect you know the story about that stupid offset keyboard, and why it's like that. LOL! But, so it goes. These are the tools we're given.
I have not been in that specific situation, but I work with embedded Linux systems so I regularly use UART for console connection to rather bare bones systems. Even though I could manually add packages to it, it's not worth the hassle for something that shouldn't be there in the end.
But for my main machine I will gladly install tools to make life easier :)
I'm not familiar with the offset keyboard. This is a bit off-topic from the original discussion, but I'm a big fan of Vim/NeoVim :). Do you mean why Vim uses hjkl for navigation? Because I googled and found it's because the creator's keyboard had arrow keys there.
yes. (wasn't trying to be off-topic there. i just meant, sometimes "you have to take what you get" )
Thank you, Gias Uddin, for this nice compilation of commands. I hope you don't mind I copy pasted it. I did give you the credit! :D
I consider it close to perfect for a nice list. My only possible other two cents would be systemctl. I was going to say, be sure to know how to use server name start , as an alternative to systemctl as well. E.g. My Linux box doesn't have systemctl unless i use an alt boot option, but it's an intentionally more lightweight system. I boot it w/ systemctl if i'm present to hit the key. It's certainly a more friendly environment.
Cheers, and thanks again!
touchis actually a command used to update the access date and/or modification date of a file - the fact that it creates the file if it doesn't exist is merely a convenient side effect.