Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

2.5 Working directory toggle command


May 23, 2021 That's what Linux should learn



A working directory is where the user is currently in the system. B ecause the working directory involves knowledge about the storage structure of the system, chapter 6 explains this in detail. Readers only need to briefly understand the operation of the experiment here, if not fully mastered it does not matter, after all, the Linux system knowledge system is too large, every beginner needs to go through such a period of time.

1. pwd command

The pwd command is used to display the working directory in which the user is currently located, in the format of "pwd . . . options".

[root@linuxprobe etc]# pwd /etc

2. cd command

The cd command is used to switch the working path in the format "cd (directory name)."

This command should be the most commonly used Linux command. Y ou can quickly and flexibly switch to different working directories with the cd command. I n addition to the usual way to switch directories, you can use the "cd -" command to return to the last directory, using "cd.." T he command goes to the parent directory, and uses the "cd-" command to switch to the current user's home directory, or to switch to another user's home directory using the "cd-username". For example, you can switch into/etc directories using the "cd path":

[root@linuxprobe ~]# cd /etc

By the same to no return, you can switch to the /bin directory using the following command:

[root@linuxprobe etc]# cd /bin

At this point, to return to the last directory (i.e. /etc directory), you can execute the following command:

[root@linuxprobe bin]# cd - /etc [root@linuxprobe etc] #

You can also quickly switch to the user's home directory with the following command:

[root@linuxprobe etc]# cd ~ [root@linuxprobe ~] #

3. ls command

The ls command is used to display file information in the directory in the format "ls (options) and "files".

The working directory is different, and the files in the current working directory are certainly different. U se the "-a" parameter of the ls command to see all the files( including hidden files), and use the "-l" parameter to view details such as the properties, size, and so on. After the two parameters are consolidated, the ls command is executed to view all the files in the current directory and output the properties of those files:

  1. >[root@linuxprobe ~]# ls -al
  2. total 60
  3. dr-xr-x---. 14 root root 4096 May 4 07:56 .
  4. drwxr-xr-x. 17 root root 4096 May 4 15:55 ..
  5. -rw-------. 1 root root 1213 May 4 15:44 anaconda-ks.cfg
  6. -rw-------. 1 root root 957 May 4 07:54 .bash_history
  7. -rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout
  8. -rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile
  9. -rw-r--r--. 1 root root 176 Dec 28 2013 .bashrc
  10. drwx------. 10 root root 4096 May 4 07:56 .cache
  11. drwx------. 15 root root 4096 May 4 07:49 .config
  12. -rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc
  13. drwx------. 3 root root 24 May 4 07:46 .dbus
  14. drwxr-xr-x. 2 root root 6 May 4 07:49 Desktop
  15. drwxr-xr-x. 2 root root 6 May 4 07:49 Documents
  16. drwxr-xr-x. 2 root root 6 May 4 07:49 Downloads
  17. -rw-------. 1 root root 16 May 4 07:49 .esd_auth
  18. -rw-------. 1 root root 628 May 4 07:56 .ICEauthority
  19. -rw-r--r--. 1 root root 1264 May 4 07:48 initial-setup-ks.cfg
  20. drwx------. 3 root root 18 May 4 07:49 .local
  21. drwxr-xr-x. 2 root root 6 May 4 07:49 Music
  22. drwxr-xr-x. 2 root root 6 May 4 07:49 Pictures
  23. drwxr-xr-x. 2 root root 6 May 4 07:49 Public
  24. -rw-r--r--. 1 root root 129 Dec 28 2013 .tcshrc
  25. drwxr-xr-x. 2 root root 6 May 4 07:49 Templates
  26. drwxr-xr-x. 2 root root 6 May 4 07:49 Videos
  27. -rw-------. 1 root root 1962 May 4 07:54 .viminfo

If you want to view directory property information, you need to add an additional -d parameter. For example, you can use the following commands to view permissions and property information for the /etc directory:

[root@linuxprobe ~]# ls -ld /etc drwxr-xr-x. 132 root root 8192 Jul 10 10:48 /etc