The Basics of Linux Commands Explained


Basic Command for New User

ls

The ls command is used to list the contents of a directory. By default, it lists the contents of the current directory. To list the contents of a specific directory, simply type the directory name after the ls command. For example, "ls /home/user/Documents" would list the contents of the Documents directory in the user's home directory.

cd

The cd command is used to change the current directory. To change to a specific directory, simply type "cd" followed by the directory name. For example, "cd /home/user/Documents" would change the current directory to the Documents directory in the user's home directory. To change to the previous directory, type "cd ..".

pwd

The pwd command is used to print the current working directory. It can be useful to know the current directory when navigating the file system or running commands that require a file path.

mkdir

The mkdir command is used to create a new directory. To create a new directory, type "mkdir" followed by the directory name. For example, "mkdir my_new_directory" would create a new directory called "my_new_directory" in the current directory.

touch

The touch command is used to create a new empty file. To create a new file, type "touch" followed by the file name. For example, "touch my_new_file.txt" would create a new empty text file called "my_new_file.txt" in the current directory.

cp

The cp command is used to copy files and directories. To copy a file, type "cp" followed by the source file name and the destination file name. For example, "cp file1.txt file2.txt" would copy "file1.txt" to "file2.txt". To copy a directory, add the "-r" flag after the "cp" command. For example, "cp -r directory1 directory2" would copy "directory1" to "directory2".

mv

The mv command is used to move or rename files and directories. To move a file, type "mv" followed by the source file name and the destination file name. For example, "mv file1.txt directory1" would move "file1.txt" to "directory1". To rename a file, simply provide the new name for the destination file. For example, "mv file1.txt file2.txt" would rename "file1.txt" to "file2.txt".

rm

The rm command is used to remove files and directories. To remove a file, type "rm" followed by the file name. For example, "rm file1.txt" would remove "file1.txt" from the current directory. To remove a directory, add the "-r" flag after the "rm" command. For example, "rm -r directory1" would remove "directory1" and all of its contents.

cat

The cat command is used to display the contents of a file. To display the contents of a file, type "cat" followed by the file name. For example, "cat file1.txt" would display the contents of the "file1.txt".

sudo

The sudo command is used to run a command with superuser privileges. This is useful for performing tasks that require administrative access, such as installing software or modifying system settings. To run

Previous Post Next Post

نموذج الاتصال