Best Linux Commands Every Beginner Must Know

Best Linux Commands Every Beginner Must Know

Linux can seem intimidating to beginners, but once you learn a few basic commands, you’ll find it much easier to navigate and use. Here are some of the best Linux commands every beginner should know, explained in simple terms.

1. ls – List Files and Directories

The ls command lists the files and directories in the current directory.

Example:

ls

2. cd – Change Directory

The cd command is used to change the current directory.

Examples:

cd /home/user/Documents
cd ..
cd ~
  • /home/user/Documents – Change to the “Documents” directory.
  • .. – Move up one directory level.
  • ~ – Go to your home directory.

3. pwd – Print Working Directory

The pwd command shows the current directory you’re in.

Example:

pwd

4. mkdir – Make Directory

The mkdir command creates a new directory.

Example:

mkdir new_directory

5. rmdir – Remove Directory

The rmdir command deletes an empty directory.

Example:

rmdir old_directory

6. rm – Remove Files and Directories

The rm command removes files or directories.

Examples:

rm file.txt
rm -r directory
  • file.txt – Delete a file.
  • -r directory – Delete a directory and its contents recursively.

7. cp – Copy Files and Directories

The cp command copies files or directories from one location to another.

Examples:

cp file.txt /path/to/destination/
cp -r directory /path/to/destination/
  • file.txt – Copy a file.
  • -r directory – Copy a directory and its contents.

8. mv – Move or Rename Files and Directories

The mv command moves or renames files and directories.

Examples:

mv file.txt /path/to/destination/
mv old_name.txt new_name.txt
  • file.txt – Move a file.
  • old_name.txt to new_name.txt – Rename a file.

9. cat – Concatenate and Display Files

The cat command displays the content of a file.

Example:

cat file.txt

10. nano – Simple Text Editor

The nano command opens a simple text editor in the terminal.

Example:

nano file.txt
  • Use CTRL + O to save and CTRL + X to exit.

11. sudo – Execute Command as Superuser

The sudo command allows you to run commands with superuser (administrator) privileges.

Example:

sudo apt-get update
  • apt-get update – Example command to update package lists on Debian-based systems.

12. man – Manual Pages

The man command shows the manual page for other commands. It’s like built-in help documentation.

Example:

man ls
  • This will show the manual page for the ls command.

13. grep – Search Text

The grep command searches for text within files.

Example:

grep 'search_term' file.txt
  • 'search_term' – Text you are searching for in the file.

14. find – Search for Files

The find command searches for files and directories in a directory hierarchy.

Example:

find /home/user -name "file.txt"
  • /home/user – Start search in this directory.
  • -name "file.txt" – Look for a file named “file.txt”.

15. tar – Archive Files

The tar command is used to create and extract archives.

Examples:

tar -czvf archive.tar.gz directory/
tar -xzvf archive.tar.gz
  • -czvf archive.tar.gz directory/ – Create a compressed archive of a directory.
  • -xzvf archive.tar.gz – Extract a compressed archive.

16. top – Display System Processes

The top command shows the system’s processes and resource usage in real time.

Example:

top
  • Use q to quit.

17. chmod – Change File Permissions

The chmod command changes the permissions of a file or directory.

Example:

chmod 755 file.sh
  • 755 – Sets the file permissions (read, write, and execute for the owner, and read and execute for others).

18. chown – Change File Ownership

The chown command changes the ownership of a file or directory.

Example:

chown user:group file.txt
  • user:group – The new owner and group for the file.

By familiarizing yourself with these basic commands, you’ll be well on your way to becoming comfortable with using Linux. Practice them regularly, and soon you’ll find navigating and managing your Linux system much easier. Happy learning!

Leave a Reply

Your email address will not be published. Required fields are marked *