Top 12 comands of linux for beginners
What are the Uses of Linux?
Linux commands are a type of Unix command or shell procedure. They are the basic tools used to interact with Linux on an individual level.
Linux operating system is used on servers, desktops, and maybe even your smartphone. It has a lot of command line tools that can be used for virtually everything on the system.
1 sudo command
Superuser do or sudo is one of the most basic commands in Linux. It runs your command with administrative or root permissions. Here’s the general syntax:
sudo (command)
When you run a sudo command, Terminal will request the root password. For example, this snippet runs useradd with the superuser privilege:
sudo useradd username
You can also add an option, such as:
-k — invalidates the timestamp file.
-g — executes commands as a specified group name or ID.
- h — runs commands on the host.
2 .ls command
ls — lists a directory’s content.
The ls command lists files and directories in your system. Here’s the syntax:
ls [/directory/folder/path]
If you remove the path, the ls command will show the current working directory’s content. You can modify the command using these options:
-R — lists all the files in the subdirectories.
-a — shows all files, including hidden ones.
- lh — converts sizes to readable formats, such as MB, GB, and TB.
3 cat command
Concatenate or cat is one of the most used Linux commands. It lists, combines, and writes file content to the standard output. Here’s the syntax:
cat filename.txt
There are various ways to use the cat command:
cat > filen.txt — creates a new file.
cat file1.txt file2.txt > file3.txt — merges file1.txt with file2.txt and stores the output in filename3.txt.
tac file.txt — displays content in reverse order.
4 .Touch command
The touch command lets you create an empty file in a specific directory path. Here’s the syntax:
touch [option] /home/directory/path/file.txt
If you omit the path, the command will create the item in the current folder. You can also use touch to generate and modify a timestamp in the Linux command line
5 .nano, vi, jed commands
Linux lets users edit files using a test editor like nano, vi, or jed. While most distributions include nano and vi, users must install jed manually. All these tools have the same command syntax:
nano filename
vi filename
jed filename
If the target file doesn’t exist, these editors will create one. We recommend nano if you want to quickly edit text files. Meanwhile, use vi or jed for scripting and programming.
6 .mkdir command
Use the mkdir command to create one or multiple directories and set their permissions. Ensure you are authorized to make a new folder in the parent directory. Here’s the basic syntax:
mkdir [option] [directory_name]
To create a folder within a directory, use the path as the command parameter. For example, mkdir music/songs will create a songs folder inside music. Here are several common mkdir command options:
-p — creates a directory between two existing folders. For example, mkdir -p Music/2023/Songs creates a new 2023 directory.
-m — sets the folder permissions. For instance, enter mkdir -m777 directory to create a directory with read, write, and execute permissions for all users.
-v — prints a message for each created directory.
7 .rmdir commanda
Use the rmdir command to Delete an empty directory in linux. The user must have sudo privileges in the parent directory. Here’s the syntax:
rmdir [option] directory_name
If the folder contains a subdirectory, the command will return an error. To force delete a non-empty directory, use the -p option.
8. cd command
Use the cd command to navigate the Linux files and directories. To use it, run this syntax with sudo privileges:
cd /directory/folder/path
Depending on your current location, it requires either the full path or the directory name. For example, omit /username from /username/directory/folder if you are already within it.
Omitting the arguments will take you to the home folder. Here are some navigation shortcuts:
cd ~[username] — goes to another user’s home directory.
cd .. — moves one directory up.
cd- — switches to the previous directory.
9. pwd command
The pwd command prints your current working directory’s path, like /home/directory/path. Here’s the command syntax:
pwd [option]
It supports two options. The -L or –-logical option prints environment variable content, including symbolic links. Meanwhile, -P or –physical outputs the current directory’s actual path.
10 . cp command
Use the cp command to copy files or directories, including their content, from your current location to another. It has various use cases, such as:
Copying one file from the current directory to another folder. Specify the file name and target path:
cp filename.txt /home/username/Documen
11 .mv command
Use the mv command to move or rename files and directories. To move items, enter the file name followed by the destination directory:
mv filename.txt /home/username/Documents
12 .history command
Enter history to list previously executed commands. It lets you reuse the commands without rewriting them. To use it, enter this syntax with sudo privileges:
history [option]
This command supports many options, such as:
-c — clears the history list.
-d offset — deletes the history entry at the OFFSET position.
- a — appends history lines.
Thanks for reading
I hope found this useful?
✅Reshare this with others so that it helps more people
✅Tag your colleagues and friends who you think will need this