Linux Basic Commands

Table of contents

No heading

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.

  1. echo: print anything to screen

  2. 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

    1. -l (long format)

    2. -a (display hidden files)

    3. -h (display file sizes in human-readable format), and many others.

  3. 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.

  4. cd new_directory; mkdir www; pwd: multiple commands execution

  5. pwd: The pwd command is used to print the current working directory.

  6. 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.

  7. 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.

    1. To remove a file named "file.txt", you can use the command rm file.txt.

    2. To remove a directory and its contents, you can use the command rm -r directory/.

  8. cp: The cp command is used to copy files and directories.

    1. To copy a file named "file.txt" to a directory named "newdir", you can use the command cp file.txt newdir/.

    2. cp -r to copy directories.

  9. 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/.

  10. touch: To create a file without contents

  11. 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.

  12. cat > filename: To add contents to the file.

  13. Ctrl + D: save data to file and exit the prompt.

  14. cat filename: To view the contents of the file.

  15. mv: Move/rename the file.

  16. 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.