Introduction

The Linux command line is an exciting place, home to many powerful tools and operations. In this article, we will dive into the basics of the Linux command line, exploring essential commands and providing valuable tips and shortcuts.

cd Command

cd /: Used to navigate to the root directory.
cd ..: Takes you one directory up.
cd ../..: Moves you two directories up.

ls Command

ls -l: Displays files and directories in a detailed format.
ls -a: Reveals hidden files and directories.
ls -la: Lists all files and directories in detailed and hidden formats.

file Command

file a.txt: Determines the type of a specified file.

What Is Bash

Bash is the most widely used command-line shell in Linux.

What Is the Linux File System

Linux treats everything as a file in its file system.

man Command

man ls: Shows the usage and documentation of the ls command.

ls -l | grep Command

ls -l | grep filename-or-foldername: Lists a specific file or directory.

exit Command

exit: Exits the command line.

rmdir Command

man rmdir: Displays the documentation for the rmdir command. rmdir folder/: Deletes the specified directory.

touch and rm Commands

touch a.txt: Creates an empty file. rm a.txt: Removes the specified file. rm -r folder/: Deletes the specified directory and its contents.

cat and tail Commands

cat a.txt: Displays the contents of a file.
tail -f a.txt: Monitors changes at the end of a file in real-time.
echo "tail learn command" > a.txt: Adds text to a file.
echo "tail learn command" >> a.txt: Appends text to a file.

echo Command

echo orion: Writes “orion” to the screen.

cp Command

cp a.txt folder/: Copies a file to the specified directory.

who Command

who: Lists users who have logged in. who -b: Shows the system’s last reboot time.

Ctrl + L Command

Ctrl + L: Clears the screen and runs the ‘clear’ command.

File Redirection and Searching Commands

ls -l > ls-l.txt: Redirects ls -l output to "ls-l.txt."
grep da * 2 > grep-error.txt: Searches for files containing "da" and redirects errors to "grep-error.txt."
grep da *: Searches for files containing "da."

which and locate Commands

which emacs: Displays the full path of the "emacs" command.
locate a.txt: Quickly finds the location of "a.txt."

These commands and tips will help you become more efficient and capable in the Linux command line.

Conclusion

The Linux command line offers a plethora of powerful tools to accelerate your daily tasks and enhance your efficiency. This article serves as an excellent resource for those new to learning Linux commands.