Linux Basic Commands
Table of contents
No headings in the article.
Linux is an open-source operating system that is widely used for various purposes, including servers, desktops, and embedded systems. It offers a powerful command-line interface (CLI) that provides users with a lot of flexibility and control over their system. In this blog post, we will cover some of the basic Linux commands that every user should know.
echo: print anything to screen
ls: The ls command is used to list the files and directories/folders in the current directory. By default, it displays the contents in a vertical list. However, you can also use various options to modify the output, such as
-l (long format)
-a (display hidden files)
-h (display file sizes in human-readable format), and many others.
cd: The cd command is used to change the current directory. For example, to switch to the home directory, you can use the command cd ~, or to change to a specific directory, you can use cd /path/to/directory.
cd new_directory; mkdir www; pwd: multiple commands execution
pwd: The pwd command is used to print the current working directory.
mkdir: The mkdir command is used to create a new directory. For example, to create a directory named "newdir", you can use the command mkdir newdir.
rm: The rm command is used to remove files and directories. However, be careful when using this command, as it permanently deletes the files and directories.
To remove a file named "file.txt", you can use the command rm file.txt.
To remove a directory and its contents, you can use the command rm -r directory/.
cp: The cp command is used to copy files and directories.
To copy a file named "file.txt" to a directory named "newdir", you can use the command cp file.txt newdir/.
cp -r to copy directories.
mv: The mv command moves and renames files and directories. For example, to move a file named "file.txt" to a directory named "newdir", you can use the command mv file.txt newdir/.
touch: To create a file without contents
cat: The cat command is used to concatenate and display files. For example, to display the contents of a file named "file.txt", you can use the command cat file.txt.
cat > filename: To add contents to the file.
Ctrl + D: save data to file and exit the prompt.
cat filename: To view the contents of the file.
mv: Move/rename the file.
rm filename: Delete the file.
These basic commands will help you become more productive and efficient when using the Linux CLI. As you become more comfortable with the commands, you can explore more advanced options and functionality to further enhance your workflow.