Check out my books on Amazon at https://www.amazon.com/John-Au-Yeung/e/B08FT5NT62
Subscribe to my email list now at http://jauyeung.net/subscribe/
Linux is an operating system that many developers will use.
Therefore, it’s a good idea to learn some Linux commands.
In this article, we’ll look at some useful Linux commands we should know.
head command outputs the first few lines of a file.
-n flag specifies how many lines to shows.
The default number of lines to show is 10.
tail outputs the last few lines of a file.
We can also use the
-n flag to specify how many lines to show.
Also, we can get the end of the file beginning with the
N -th line with:
tail -n +N
cat concatenates list of files and send them to the standard output stream.
less is a quick tool to let us view a file.
It opens up the file content with a read-only window.
nano is a small text editor.
It’s easy to use for beginners since we don’t have to learn lots of shortcuts.
nedit is a small graphical rextr editor.
And it lets us edit text with point and click, drag and drop, and syntax highlighting.
touch lets us modify the timestamp of an existing file and quickly create a new file.
logout lets us exit the shell we’re logged into.
ncdu lets us display file space usage.
It opens a window that shows the disk usage of each file.
top displays all currently running processes and their owners, memory usage, and more.
htop is an interactive version of
We can pass
-u username to display processes that are owned by user
whereis lets is search for files related to a particular command.
For instance, we run:
to find the path to the
ls command and the associated manpage.
whatis prints the description of the command from its man page.
locate command finds a file anywhere in the system by searching a cached list of files.
find iterates through the file system to find the file we’re looking for.
It looks at files that currently exist in the system.
find lets us search by file age, size, ownership, type, timestamp, permissions, depth within the file system, regex, and more.
wget lets us download a file from the Internet
curl can be used like
wget , but we need the
curl supports many moe protocols and it’s more widely available that
wget can only receive data, but
curl can also send data.
wget can download files recursively, but
apt command is available in Debian based distros.
It can be used to install, upgrade, or delete software on our machine.
We can run
apt search to search for packages.
apt install lets us install packages.
Linux distros comes with many commands that we can use to manage files and download files.