Basic Linux Commands For Beginners
If we work as developers, we’ve to work with the Linux command line eventually.
In this article, we’ll look at some basic Linux commands we should know to work with the Linux command line.
pwd
pwd stands for Print Working Directory. It shows the directory that we’re in now.
ls
ls lists the files and directories that are in the current directory.
cd
cd stands for change directory. It lets us change directory to a different directory by typing in the directory name we want to switch to after cd.
mkdir
mkdir lets us make a new directory in the current working directory by typing in the directory name after mkdir.
rmdir
rmdir is used to remove the directory with the given name.
lsblk
Lists the available block devices in a system. A block device gives us access to a device in a way where the hardware characteristics of the device isn’t visible.
mount
We can use the mount command to mount a removable storage device. This makes it available for us to use.
df
The df lets admins monitor and analyze server status and network systems.
uname
Gets the Linux version information of the operating system we’re currently using.
ps
Lists the tasks that currently running on our system.
kill
kill lets us end tasks that are currently hung in our system.
service
The service command lets us run system-wide services from the terminal.
batch
batch lets us run system services in a predefined schedule.
shutdown
shutdown does what its name says. It shuts down our computer.
touch
touch lets us create a new text file by typing in a file name after it.
cat
cat is used to concatenate multiple files by specifying file paths of text files after it to concatenate them together.
head
The head command lets us view the head of the file by typing in the file path of the text file we want to view after it.
tail
The tail command lets us view the tail of the text file as it’s being updated. The updates are done live so we’ll always see the latest.
cp
cp lets us copy files from one place or another and if it’s the same directory, it’ll rename the file.
mv
mv is short for a move. It lets us move files around our system. We can use the -f switch to force the operating system to move big files.
comm
The comm command is the command to compare 2 files.
less
The less command is popular for viewing the contents of files. We can let users navigate within a file in both directions with this file.
ln
ln is used for creating symbolic links to some files for easy access.
cmp
We can use cmp to compare files and output the results to an output stream.
dd
The dd command is used to convert and copy files. We can use it to make hardware and device files appear in the file system like normal files.
After running dd, those devices will show up like regular files.
alias
The alias command lets us replace a word by another string. This helps us replace long commands with shorter ones.
cal
This is a small calendar program that we can run to get some information about today’s date and other things.
fortune
The fortune command lets us see the fortune that we get for the day. It has funny and inspirational quotes.
history
The history commands prints out the commands that we typed and see what we’ve done in the terminal recently.
yes
Typing yes and then some text after it just displays the text after yes forever until we stop it with Ctrl+C.
banner
The banner command gives us the ability to make our own ASCII banners that we can see on the command line.
rev
The rev command takes text input and writes them to the standard output and reversing each character. It’s useful for pranks.
wget
wget lets us download files from the Internet right from the terminal. It works with HTTP, HTTPS, and FTP servers.
iptables
iptables lets sysadmins control incoming and outgoing traffic on a host machine. It’s used on a regular basis to define authentic traffic and blacklist suspicious or untrusted requests.
Killall
If you have a slow ‘Google Chrome’ and want to kill all running and open chrome instances, or if you have a Notes app that is not responding, killall is an easy command that can help you.
Killall exactly matches the argument name by default and kills the matching process. Here is how to use it.
Ctrl + x + e
If you want to write a long command, but you do not want to type it on your terminal for many obvious reasons, this shortcut will help.
Ctrl + x + e will open an editor where you can type your command. And upon saving the editor, the command will run on the terminal.
tee
The tee
command in UNIX is a command-line utility for copying standard input to standard output. It supports writing whatever it is given from standard input to standard output and optional writing to one or more files. That’s especially helpful when you want to redirect data to a file as well as see what's in the file.
The command is named after the T splitter used in plumbing.
This is how we can use the command.
sl
This is a bonus command.
If you want to relieve the pressure after some hard hours at work, or you just want to stare at something else, ‘sl’ is the command for you. Linux can be funny at times!!
This is how you install ‘sl’
brew install sl
I believe, no matter whether you’re a seasoned Linux user like me or a beginner who’s just starting to get his feet wet in this fantastic world of Unix systems, mastering the various terminal commands is a must for everybody.
And I hope you all learned something new today. Share your fancy Linux commands in the comments section.
Subscribe to my newsletter
Read articles from Sauradip Ghosh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by