Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux- basic command

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Cd command

Full name: change Directory

Function: modify the directory in which it is located

Format: cd / etc/sysconfig

Pwd

Special actions:

Cd /: switch directly to the root directory

Cd ~: return to the current user's home directory

Cd.: return to the directory one level above the current location

Cd -: return to the directory where you were last time (return to the directory before you switched to the directory)

Add:

A home directory is essentially a directory. Each user in linux has his or her own.

This directory is the user's home directory, and the user can perform any operation in the home directory.

There are two situations in the user's home directory

1. Root user: / root

2. Ordinary user: the directory under / home that is the same as the user name is the user's home directory.

For example: user zhangsan, home directory / home/zhangsan directory

For example, user zhangsan executes the command cd ~ and switches to / home/zhangsan

User sy executes the command cd ~ and switches to / home/sy

Useradd zhangsan

Passwd

Cd ~

Pwd

Useradd lisi

Passwd

Cd ~

Pwd

Exercise:

1. Change to the directory / etc/sysconfig

[root@localhost ~] # cd / etc/sysconfig

[root@localhost sysconfig] # pwd

/ etc/sysconfig

2. Change to the / home directory

[root@localhost ~] # cd / home/

[root@localhost home] # pwd

/ home

3. Change to the directory / etc/sysconfig

[root@localhost ~] # cd / etc/sysconfig

[root@localhost sysconfig] # pwd

/ etc/sysconfig

4. Return the current user's home directory

[root@localhost sysconfig] # cd ~

[root@localhost ~] # pwd

/ root

[root@localhost ~] # su zs

[zs@localhost root] $cd / etc/

[zs@localhost etc] $cd ~

[zs@localhost ~] $pwd

/ home/zs

5. View the current location

[root@localhost ~] # su zs

[zs@localhost root] $cd / etc/

[zs@localhost etc] $cd ~

[zs@localhost ~] $pwd

/ home/zs

6. Return to the root directory of the system

[zs@localhost /] $su root

Password:

[root@localhost /] # cd /

[root@localhost /] # pwd

/

2. Pwd command

Full name: Print Working Directory

Function: print the directory (working directory)

All files in linux are stored in the root directory

/: indicates the root directory of linux (directory name is /)

3. Mkdir command

Full name: make Directory

Purpose: create a directory

Format: mkdir [OPTION]... DIRECTORY...

Example: create three directories bajie wukong guodegang

[root@localhost ~] # mkdir bajie wukong guodegang

[root@localhost ~] # ls

Bajie guodegang test1 wukong

Example: create three directories / yunwei/linux/python

[root@localhost ~] # mkdir yunwei/linux/python

Mkdir: cannot create directory yunwei/linux/python': No such file or directory error, no parent directory option:-p: create a parent directory first and then create a subdirectory when creating a directory. -v: display the process information for creating a directory [root@localhost ~] # mkdir-p yunwei/linux/python [root@localhost ~] # lsbajie guodegang test1 wukong yunwei example: create a directory / a1/a2/a3 and display the process information for creating a directory [root@localhost ~] # mkdir-pv a1/a2/a3mkdir: created directorya1'

Mkdir: created directorya1/a2 'mkdir: created directorya1/a2/a3'

[root@localhost ~] # ls

A1 bajie guodegang test1 wukong yunwei

Example: create yw1 under home

# mkdir-p/home/yw1

Example: create a directory yw1 under the root directory

# mkdir / yw1

Example: create a directory yw1 under the current user's home directory

# mkdir / root/yw1

# mkdir ~ / yw1

Example: create a directory yw1 under the current location

# mkdir yw1

# mkdir. / yw1

Example: create a directory yw1 in a higher-level directory

# cd..

# mkdir yw1

Or

# mkdir.. / yw1

Add: when indicating the path

. /: indicates the current location (if you do not specify a path also means the current location)

.. /: indicates the directory at the next level

Mkdir abc > create a directory abc under the current location

Mddir. / abc > > create a directory abc under the current location

Echo "mkdir abc" output mkdir abc

[root@localhost tmp] # echo "mkdir abc"

Mkdir abc

[root@localhost tmp] # ls

Yw1

That's all, thank you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report