Most used basic Linux commands

Tram Ho

The most common basic Linux commands

1. ls

Displays a list of files and folders in the current directory. Example: ls – displays a list of files and directories in the current directory

When you want to display the date and time (2) along with the ownership of the user (3), the permissions that the user can do (read, edit, delete) (4) we can use:

Clearly see the size of the file (for directories may be wrong)

2. cd

Navigate to the desired folders. (used a lot to move)

Before using it, it is necessary to learn how to distinguish specific folders.

cd ~ is where? cd / is where? (if you are still confused, you can watch the youtube video to understand better)

~: is the directory of the user that we are logged in

/: is the root directory of the server

eg:

3. mkdir

Create folder

Ex:

If you want to create a longer path, add the -p option

Vd

mkdir -p /home/download/picture

4. Touch

Create a new file. I still don’t understand why it’s called touch :v, it must be created if you want to touch. I think so

Vd

5. share

Clone (copy) a folder or a certain file

If you want to copy a directory, add the -r option

6. mv

Move the file or folder somewhere else. In particular, it can also be used to rename a file or a folder

Ex:

Ex:

7. rm

This command is quite dangerous, knowing why it is dangerous, you can vaguely guess its English, right? That’s remove 😊. When using this command, remember not to drink alcohol. Sometimes a project is lost because of this command!!!

Its syntax is

rm

When pressed it will ask you again if you want to delete or not.

If you find it too annoying, you can add the following option

Removed from needing to ask.

If you want to delete the directory, add the -r . option

nice

8. cat

Display the contents of the file on the terminal always.

eg:

9. grep

This command is very divine if you know how to use it in combination with other commands. Learn it because I think I will use it quite a lot.

It is used to find related keywords if you combine with :

List out files with keywords in grep.

Used with the command

List used commands with keyword in grep

10. chmod

When doing DBA or Devops related to the operating system, you may be able to get or thanks to this file’s permission, that directory’s permission, this will be the command to help you.

Usually I use the command

(Full decentralization, anyone can do anything, but only use it when they understand that no one will destroy that file)

If you want to assign such permissions to the directory and the sub-files in that directory, you add the option -R

Conclude.

Wish you familiarize yourself with these basic commands, mastered, the job will be very easy later. Stay tuned for part 2 if you want to know more.

Share the news now

Source : Viblo