TRÄW🤟 Profile picture
Linux & fun, I use Arch (BTW). Digital nomad, Network Engineer. Bootstrapping (@sysxplore).

Dec 8, 2021, 59 tweets

70+ basic Linux🐧 commands explained.

Hey everyone👋! I am finally BACK with another Linux🐧 thread!

In today's thread🧵, I will be going over basics commands every Linux user should know !

A Mega🧵 thread

Have grouped these commands so you can easily Identify their usage.

- Linux Manual/Help Commands
- Linux File Commands
- Linux Directory Commands
- Linux File Content Commands
- Linux User Commands
- Linux Filter Commands
- Linux Utility Commands
- Linux Networking Commands

Pro tip💡: There is no need to memorize all the commands options/arguments, just make use of the help menu or manual pages to find the usage of a specific command/option you want.

continue to read👇

🐧 Linux Manual/Help📑 Commands

1. man
The man command is used to display the user manual of any command that we can run on the terminal.

2. whatis
Whatis command is used to get a one-line manual page description of a command.

🐧 Linux File🧾 Commands

3. cat Command
The cat command is a multi-purpose utility in the Linux system. It can be used to create a file, display content of the file, copy the content of one file to another file, and more.

4. touch
The touch command is used to create empty files and also change file timestamps. We can create multiple empty files by executing them once.

5. rm
The rm command is used to remove a file or files. Be wary when using this command, this command can be dangerous if you don't use it properly.

For more details on the dangers of this command check out this thread.

6. cp
The cp command is used to copy a file(s) or directory(ries) from one location to another.

7. mv
The mv command is used to move/renaming a file(s) or a directory(ries) from one location to another location. A file can be renamed during a move process using the mv command.

This command can be dangerous too if you use it improperly, refer to this if you want to know the dangers.

8. rename
This command is useful for renaming files or a group of files on Linux.

🐧Linux Directory📂 Commands

9. pwd
pwd stands for print working directory. It is used to display the location of the current working directory you are current working in.

10. mkdir
mkdir stands for make directory, this command is used to create directory and subdirectories in any directory.

11. rmdir
rmdir stands for remove directory, it is used to to delete directories

12. rm
This command can also delete folders when used with the combination -rf options.

-f, --force
ignore nonexistent files and arguments, never prompt

-r, -R, --recursive
remove directories and their contents recursively

13. ls
Ls is the most used command in Linux, this command is used to list the contents of directory/subdirectories. The ls has a lot of handy options which I would advise you to check the help or man pages if you want to know more about them.

14. cd
Change Directory (cd) - used to change the current working directory to another directory.

🐧Linux File Content📜 Commands

15. head
This command is used to display the content of a file. It displays the first 10 lines of a file but default, but you can always change it to display first number of lines specified.

16. tail
This command similar to the head command. The difference is that this command displays the last ten lines of the file content by default, but you can always change this behavior if you want. It is useful for reading the error message.

17. tac
tac is the reverse of cat command, you can clearly see that from its name. It displays the file content in reverse order (from the last line).

18. more
The more command is quite similar to the cat command, as it is used to display the file content in the same way that the cat command does. But the main drawback of the cat command is that you can’t control what’s happening after you start it.

The more command displays a text fi le, but stops after it displays each page of data.

19. less
Similar to the more command, the less command is an advanced version of the more command. (the less command name comes from the phrase “less is more”) It also includes some extra features such as 'adjustment in width and height of the terminal.

Refer to this thread if you want to know more about these commands:

🐧Linux User/Group👨‍👨‍👦 Management Commands

20. su
This command allows administrative access to another user. It allows access of the Linux shell of another user. It also run a command with substitute user and group ID.

21. id
command is used to display the effective user ID (UID) and effective group ID (GID).

22. useradd
useradd command is used to add or remove a user on a Linux server
-m - create home directory
-p - new user password
-s - user login shell
xtremepentest - new username

23. adduser
Similar to the useradd command, the adduser is also used to add users on a Linux system. This command provides an interactive way of adding a user unlike the useradd command.

24. usermod
Used to modify a user account i.e changing user home directory, username, enforcing password expiry policies, changing user groups, etc.

Here we are changing the user xtremepentest's password and login shell.

25. chfn
This command is used change real user name and information.

26. finger
user information lookup program. This command displays specified user information. By default it displays the currently logged in user information.

27. groupadd
The groupadd command is used to create a user group.

28. addgroup
Similar to the groupadd command, addgroup is also used to create user groups.

The only difference is that groupadd is usually preferable for scripting (say, if you wan't to create users in batch), whereas addgroup is more user friendly (especially if you are unfamiliar with all the options and flags).

29. groupmod
this command is used to modify a group definition on the system

30. groups
print the all the groups a user is in.

31. users
print the user names of users currently logged in to the current host.

32. who
show who is logged on

33. whoami
print effective userid

🐧Linux Filter/Text📑 Manipulation Commands

34. cut
This command is used to select a specific column of a file. The '-d' option is used as a delimiter, and it can be a space (' '), a slash (/), a hyphen (-), or anything else. And, the '-f' option is used to specify a column number. Example: printing all available usernames

35. grep
grep is the most powerful and used filter in a Linux system. The 'grep' stands for global regular expression print." It is useful for searching the content from a file. Generally, it is used with the pipe.

36. comm
The comm command is used to compare two files or streams. By default, it displays three columns, first displays non-matching items of the first file, second indicates the non-matching item of the second file, and the third column displays the matching items of both files

37. sed
Sed command is also known as stream editor. It is used to edit files using a regular expression. It does not permanently edit files; instead, the edited content remains only on display. It does not affect the actual file. Here is an example of substituting words.

38. gawk/awk
gawk command in Linux is used for pattern scanning and processing language. The awk command requires no compiling and allows the user to use variables, numeric functions, string functions, and logical operators.

39. tee
The command is quite similar to the cat command. The only difference between both filters is that it puts standard input on standard output and also write them into a file.

40. tr
This command is used to translate the file content from lower case to upper case, delete characters.
Here is an example of deleting ":" character

Here is an example of translating characters:
In this example I have translated all ":" to "-".

41. diff
The diff command simply compares two text sources/text files and outputs their differences. It compares the files line by line to find the differences.

42. uniq
is used to form a sorted list in which every word will occur only once.
Note💡: 'uniq' does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use 'sort -u' without 'uniq'.

43. sort
command is used to sort files in alphabetical order. It also used in place of the uniq command

44. wc
command is used to count the lines, words, and characters in a file.

45. od
command is used to display the content of a file in different formats, such as hexadecimal, octal, and ASCII characters.

46. nl
Displays line numbers in a file.

SECOND PART OF THE THREAD.

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling