Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to manage files and directories in Linux

Shulou Source: shulou.com Published: 2022-06-02 06:01:23 09月14日 Update

Today, I will talk to you about how to manage files and directories in Linux. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

Linux files and directories manage directories and paths

. On behalf of this layer directory.. Represents the upper level directory-represents the previous working directory ~ represents the home folder where the "current user identity" is located ~ account represents the home folder of the user account (account is an account name)

Let's talk about a few common instructions for processing directories:

Cd: changing directories

Pwd: displays the current directory

Mkdir: create a new directory

Rmdir: delete an empty directory

Cd (change directory, transform directory)

Variable about the executable file path: $PATH

Example: what is the search path listed with the identity of root?

[root@study ~] # echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

If you want root to execute ls under / root in any directory, add / root to PATH. The way to join is simple, like this:

[root@study ~] # PATH= "${PATH}: / root" file and directory management

View of files and directories: ls

Copy, delete and move: cp, rm, mv

Consult the contents of the document

Cat displays the contents of the file from the first line

Tac displays from the last line, and you can see that tac is written backwards for cat!

When nl is displayed, output the line number by the way!

More displays the contents of the file page by page

Less is similar to more, but even better than more, it can turn the page forward!

Head only looks at the first few lines

Tail only looks at a few lines of tail.

Od reads the contents of the file in a binary way!

Modify the file time or create a new file: touch

The most commonly used touch directive is:

Create an empty file

Revise a file date to current (mtime and atime)

Default and hidden permissions for files and directories

File default permissions: umask

[root@study ~] # umask0022

Tags: File directory permission representative content user management special instruction system management file attribute file name example path face important line name number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MariaDB Microsoft Linux Huawei