Mastering Linux Commands

Learn the art of using commands to execute your daily needs.

Mastering Linux Commands

Introducing Linux

Hello Reader! Today we'll be getting over linux commands that will be helpful in many different aspects of Computer Science.

So basically, Linux is a kernel when combined with various software components and graphical user interfaces, it forms a complete and functional Operating System.

What makes Linux diverse is the availability of different versions, known as distributions. These distributions vary in terms of the softwares they include, the user interfaces they offer, and the features they provide. Some are even categorized based on the user needs like:

  • Ubuntu and Fedora for normal day-to-day user's needs.

  • Kali and Black Arch Linux for security professionals and penetration testers.

  • Arch Linux for more customization and control over operating system and computer hardware.

  • and many more

Using Command Line Interface

Almost all the distributions of linux can be used and managed by 2 ways:

  • Graphical User Interface

This is the snapshot of a typical Ubuntu Linux Desktop Environment. This contains all the applications and softwares currently presented in the machine.

  • Command Line Interface

This the typical image of ubuntu terminal through which you can do almost all the task which can be done by GUI (Graphical User Interface).

But there is something needs to be covered, and that is the commands which would be executing these tasks. We'll be going through it in some time.

Commands

manIt is used for user manual, getting information about any command.
pwdIt is used for getting information about the current working directory.
cdIt is used for changing or navigating through any directory.
lsIt is used to get the list of contents in that directory.
ls -aIt is used to show all the files including hidden ones.
ls -RIt is used to get all the sub-directories (works recursively).
ls -lIt is used to get all the information of the files apart from names in tabular format.
ls -laThis will include both features of l and a.
ls -lahIt is used to get the size of files in kb, mb formats.
clearIt is clearing the terminal by removing all the previous commands.
mkdirIt is used to create a new directory.
rmdirIt is used to remove a directory.
mkdir -p folder1/folder2/folder3It is used to create a directory within a directory in a single command. Basically, a directory tree.
rmdir -p folder1/folder2/folder3It is used to delete a non-empty directory tree.
rm <file name>It is used to delete a file.
rm -iIt is used to ask permission to delete a file (type yes to actually delete).
rm -RIt is used to delete the directory.
rm -rfIt is used to forcefully delete the directory.
touchIt is used to create a new file (more than one file can be created by space between names).
fileIt is used to get information/type of a file.
mv <file1> <file2>It is used to rename a file within the same directory.
headIt is used to print initial content/lines to give an overview of the file.
tailIt is used to print the last content/lines of a file.
moreIt is used to display content page by page. (use spacebar to navigate to different pages).
open <file name>It is used to open file or directory.
df -mIt is used to check disk space in mb.
df -hgIt is used to check disk space in human readable Gb format.
catIt is used to print all the contents in a file.
cat <file name> > <new name>It is used to rename the file.
cat > <file name>It is used to write something in the file. Type ctrl+D to save and exit the writing window.
echo <content>><file name>It is used to write a content to an existing file or create a new one if it did not existed earlier.
ifconfigIt is used to show the network information like IP, domain, etc.
sudosuperuser do. It is used to access and execute restricted files and operations.
aptIt is to install an update package (advanced package management tool).
sudo apt updateIt is used to update the packages from the repository.
sudo apt upgradeIt is used to upgrade the packages and caches.
apt list --upgradableThis will list all the packages that are about to upgrade.
sudo apt install "package name"It is used to install packages which were downloaded from snap store.
cp <file name> <location> <new name>It is used to copy a file in a different directory.
mv <file name> <path/new name>It is used to move and rename at the same time.
sudo apt remove "package name"It is used to uninstall the package.
diff <file 1> <file 2>It is used to compare the difference between 2 files and display them.
locate “*.txt”It is used to locate all the files with the name .txt.
find .It is used to find the files in the current directory (.. for the previous directory).
chmod u=rwx,g=rx,o=r <file name> [u=user, g=group, o=others]It is used to change the permission for the file.
whoamiIt is used to check the person who is logged in as.
sudo chown root <file name>It is used to change the owner permission (here giving the root access).
grep “text to find” <file name>It is used to find the text within the file in the system. Prints it if it exists over there. (Case-Sensitive)
grep -w “text” <file name>It is used to print the full text. Use iw to use as not case sensitive.
grep -win “text”./*.txtIt is used to search for text in all the files and prints its location, line number and text if it exists.
historyIt is used to show all the previously used commands.
wgetIt is used to install files from the internet.
aliasIt is used to show all the short forms of the commands. You can set the aliases, then it will work for that session only.
topIt is used to see all the processes are running and their resources consuming.
zip <destination file> <source file>It is used to compress and zip the files. Unzip is the reverse.
lscpuIt is used to get the CPU details.
nslookupIt is used to get the information of server and address.
“command 1” & “command 2”It is used to run 2 commands simultaneously by running one in the background.
echo “first” && echo “second”It is used to execute the second command only when the first has been executed. (Like if else statement)

Conclusion

As you journey through the realm of Linux commands, remember that practice makes perfect. Although this will cover most of the commands which can be used in day-to-day task. But still, I would recommend you to explore more commands to become a Linux Wizard and flex in front of your friends.

In conclusion, diving into the world of Linux commands is similar to unlocking a treasure of efficiency and power. With each command mastered, you not only enhance your technical powers but also open doors to endless possibilities in system administration, development, and beyond.

As you bid farewell to this guide, let it be a catalyst for your ongoing search for Linux mastery. Let your command line journey be filled with discovery, innovation, and the satisfaction of true expertise. The Linux universe awaits ahead and make it your own.