As a beginner in Linux, it can be overwhelming to know where to start. Understanding basic Linux commands is crucial to navigating and interacting with the operating system. In this article, we will cover 20 essential Linux commands for beginners.
Beginner's Guide to Basic Linux Commands
Linux is a powerful operating system that provides a command-line interface to interact with the system. Here are some basic Linux commands for beginners:
- ls: List the contents of a directory.
- cd: Change the current working directory.
- pwd: Print the current working directory.
- mkdir: Create a new directory.
- touch: Create a new file.
- cp: Copy a file or directory.
- mv: Move or rename a file or directory.
- rm: Remove a file or directory.
- cat: Display the contents of a file.
- less: Display the contents of a file one page at a time.
- head: Display the first few lines of a file.
- tail: Display the last few lines of a file.
- grep: Search for a pattern in a file.
- find: Search for files and directories.
- chmod: Change the permissions of a file or directory.
- chown: Change the owner of a file or directory.
- kill: Terminate a process.
- top: Display the system resource usage.
- df: Display the disk usage.
- tar: Create or extract a tar archive.
- ssh: Connect to a remote system using SSH.
- scp: Copy files between systems using SSH.
- sudo: Execute a command with superuser privileges.
These commands are just the tip of the iceberg, and there are many more commands available in Linux. To learn more about these commands and how to use them, you can refer to online resources such as.
Know Where You Are: Print Working Directory (pwd)
The pwd command is used to print the working directory, which is the directory you are currently in. This is useful for navigating and understanding the file structure of your system.
Show Directory Contents: List (ls)
The ls command is used to list the contents of a directory. It provides information such as file names, file permissions, and file sizes.
Move Between Folders: Change Directory (cd)
The cd command is used to change the current working directory. It allows you to navigate through the file system and access files in different directories.
Take a Quick Look at the File Contents: Cat
The cat command is used to display the contents of a file. It can be used to quickly check the contents of a file without opening it in a text editor.
Rename Files and Folders: Move and Rename a File (mv)
The mv command is used to move and rename files and directories. This can be useful for organizing files and directories or renaming files for better clarity.
mv file_name new_file_name
Copy Files and Folders: Copy a File (cp)
The cp command is used to copy files and directories. This can be useful for creating backups or duplicating files for editing.
cp file_name new_file_name
How to Delete Files: Remove a File (rm)
The rm command is used to remove files and directories. It is important to be cautious when using this command as it permanently deletes files.
Create and Delete Folders: Make Directory (mkdir), Remove Directory (rmdir)
The mkdir command is used to create new directories, while the rmdir command is used to remove them.
mkdir new_directory rmdir directory_name
Create Blank Files: Touch
The touch command is used to create blank files. This can be useful for creating files that will be edited later.
Grant SuperUser Permission: Escalate Privileges (sudo)
The sudo command is used to escalate privileges and perform actions that require superuser permissions. This can be useful for installing software or making system-level changes.
Linking Directories and Files: ln
The ln command is used to create links between files and directories. This can be useful for creating shortcuts or organizing files.
ln -s file_name link_name
Get a Preview of the File: Head, Tail
The head and tail commands are used to preview the beginning or end of a file, respectively. This can be useful for quickly checking the contents of a file.
head file_name tail file_name
Adjusting File and Folder Permissions: Change Permissions (chmod)
The chmod command is used to change the permissions of a file or directory. This can be useful for controlling who has access to files and directories.
chmod permission file_name
Has Someone Tampered with My File?: md5sum
When you're working with important files, you want to make sure that they haven't been tampered with. The md5sum command can help you verify the integrity of your files.
To use md5sum, navigate to the directory where the file is located and run the following command:
$ md5sum filename
Search for a File: Locate, Find
Searching for files on your system can be time-consuming if you don't know where to look. Luckily, Linux provides several tools for finding files, such as the locate and find commands.
The locate command searches a pre-built database of files, which makes it much faster than find. To use it, simply enter the following command followed by the name of the file you're searching for:
$ locate myfile.txt
The find command is more versatile than locate because it can search for files based on various criteria such as size, modification date, or owner. The basic syntax for find is:
$ find /path/to/search -name "filename"
For example, to find all files with the name “example” in the current directory and its subdirectories, use the following command:
$ find . -name "example"
Check Disk Space Usage: df
It's important to keep track of how much disk space you're using, especially if you're running low on storage. The df command (short for disk free) displays information about the file system usage on your computer.
To display the disk space usage in a human-readable format, use the -h option:
$ df -h
This will display the file system usage in a format that is easy to read, with sizes shown in gigabytes, megabytes, or kilobytes.
Check Your RAM: Free
To check the amount of free memory on your system, use the free command. It displays the total amount of memory, the amount of used memory, and the amount of free memory.
To display the output in a human-readable format, use the -h option:
$ free -h
This will display the memory usage in a format that is easy to read, with sizes shown in gigabytes, megabytes, or kilobytes.
Zip Your Files: zip
The zip command allows you to create compressed archives of files and directories. This can be useful for sending files over the internet or storing them in a smaller amount of space.
To create a zip archive of a file or directory, use the following command:
$ zip archive.zip file.txt
This will create an archive called archive.zip that contains file.txt. You can also include multiple files and directories by listing them all after the archive name:
$ zip archive.zip file1.txt file2.txt dir1
To extract the contents of a zip archive, use the unzip command:
$ unzip archive.zip
Discover Basic Information about the System: uname
The uname command displays basic information about the system you're running. This includes the kernel version, operating system, and processor type.
To display this information, simply enter the following command:
$ uname -a
This will display a line of text that contains information about your system.
Learn More about Various Commands: man
Finally, one of the most important commands for beginners is man, which stands for manual. The man command provides documentation for each of the commands on your Linux system. For instance, to read more about the cd command:
$ man cd
This will display the manual page for the cd command, which includes detailed information about how to use it and what options are available.
Learning basic Linux commands can seem overwhelming at first, but once you understand the basics, you'll find that the command line is a powerful tool for managing your computer. By mastering the commands outlined in this article, you'll be well on your way to becoming a Linux power user.
What is the difference between a terminal and a command line
A terminal and a command line are related but different concepts. A terminal is a program that provides a text input and output environment, while a command line is a method of exchanging input and output via a text window. The terminal is the software application on your computer that takes inputs and shows the output, while the command line is the line in which you type the current command. The shell is the command-line interpreter, which translates the input you give to the terminal. In summary, the terminal is a program that acts as a wrapper and allows us to enter commands that the computer processes, while the command line is the method of exchanging input and output via a text window.
how to navigate directories in Linux using commands
To navigate directories in Linux using commands, you can use the cd command. cd stands for “change directory” and is used to move from one directory to another. To move to a specific directory, you can use the absolute or relative path. An absolute path starts from the root directory, while a relative path starts from the current directory. For example, to move to the /etc/ssh directory using an absolute path, you can use the command cd /etc/ssh. To move to a directory that is one level up from the current directory, you can use the command cd … To list the contents of a directory, you can use the ls command. To learn more about navigating directories in Linux, you can refer to online resources such as
how to access the command line in Linux
To access the command line in Linux, you need to open a terminal. A terminal is a program that provides a text input and output environment. In most Linux distributions, you can open a terminal by pressing Ctrl+Alt+T or by searching for “terminal” in the applications menu. Once you have opened the terminal, you can start typing commands and pressing enter to execute them. The default shell in most Linux distributions is Bash, which is a command-line interpreter that translates the input you give to the terminal. You can use various commands to navigate the file system, create and edit files, manage processes, and perform other tasks. To learn more about using the Linux command line, you can refer to online resources such as.