Skip to main content

Command Palette

Search for a command to run...

Basic Linux Commands

Published
โ€ข2 min readโ€ขView as Markdown
Basic Linux Commands

Table of Contents:

  1. View the contents of a file

  2. Change file permissions

  3. Check command history

  4. Remove a directory/folder

  5. Create and view the content of a file

  6. Add content to fruits.txt

  7. Show the top three fruits

  8. Show the bottom three fruits

  9. Create and view the content of another file

  10. Add content to Colors.txt

  11. Find the difference between fruits.txt and Colors.txt

1. View the contents of a file ๐Ÿ“„ To see what's written in a file, we use the cat command. For example:

2. Change file permissions ๐Ÿ”’ To modify the access permissions of files, we use the chmod command. It allows us to add or remove read, write, and execute permissions. For example:

3. Check command history โณ To view the list of commands you have run in the current session, simply use the history command:

4. Remove a directory/folder ๐Ÿ—‘๏ธ To delete a directory and all its contents, we use the rm command with the -r (recursive) option. For example:

5. Create and view the content of a file ๐Ÿ“ To create a new file, we use the touch command. For instance, to create a file named fruits.txt, we write:

To view the contents of fruits.txt, we can use the cat command as mentioned earlier.

7. Show the top three fruits ๐Ÿฅ‡๐Ÿฅˆ๐Ÿฅ‰ To display only the top three fruits from fruits.txt, we use the head command with the -n option:

8. Show the bottom three fruits ๐Ÿฅ‰๐Ÿฅˆ๐Ÿฅ‡ On the other hand, to view only the bottom three fruits from fruits.txt, we use the tail command with the -n option:

10. Create file Colors.txt and add content ๐ŸŸฅ๐ŸŸฉโฌœโฌ›๐Ÿ”ต๐ŸŸ ๐Ÿ’œ๐Ÿ”ณ

11. Find the difference between fruits.txt and Colors.txt โž–๐Ÿ”„โž• To discover the differences between these two files, we use the diff command:

Happy Learning !!