Implementation code case of Linux directory switching

  • 2021-08-31 09:49:01
  • OfStack

File directory switching is a very common operation in linux. When you first learned linux, the first command you came into contact with was file switching.

pwd: Displays the current directory

~: root Directory

/: Root directory

ls: View all files and directories in the current directory

cd usr Switch to the usr directory under this directory

cd../Switch to Layer 1 directory

cd/Switch to System Root

cd ~ Switch to User Home Directory

cd-Switch to the previous directory (return)

Code instance


yangw@codecompile:~/RK3288_Lakala/kernel/arch/arm/boot/dts$ cd -
  /home/yangw
  yangw@codecompile:~$ pwd
  /home/yangw
  yangw@codecompile:~$ cd - 
  /home/yangw/RK3288_Lakala/kernel/arch/arm/boot/dts
  yangw@codecompile:~/RK3288_Lakala/kernel/arch/arm/boot/dts$ pwd
  /home/yangw/RK3288_Lakala/kernel/arch/arm/boot/dts
  yangw@codecompile:~/RK3288_Lakala/kernel/arch/arm/boot/dts$ cd ~
  yangw@codecompile:~$ pwd
  /home/yangw
  yangw@codecompile:~$ cd /
  yangw@codecompile:/$ pwd
  /
  yangw@codecompile:/$ cd -
  /home/yangw

Related articles: