Several cd shortcuts
Cd is a command that engineers use every day. Today I will share some tips related to cd.
Cd
If you use cd ~ To enter the home directory of the current user, you can try typing cd directly. Similarly, double-click the keyboard.
Cd-
Cd-switched from the last two working directories. For example, it is under/usr and then cd/var. If you want to return to/usr, you can use cd -.
Cd ~ Username
This command can directly go to the home directory of username.
Cd + ls
According to my observation, the next command sent by many engineers after the cd is ls. Therefore, you can consider combining the two commands. In the. bashrc file, after you add the following code to the directory, the files in the directory will be listed:
Function cd () {builtin cd $ {1:-$ HOME} & ls ;}Mkdir + cd
After a new directory is created, it usually enters the directory. Therefore, the two commands can be combined. In the. bashrc file, add the following code and run mkdircd to create a directory and enter it.
Function mkdircd () {mkdir-p "$ @" & eval cd "\" $ #\"";}
In some distributions of Linux, you can use the .. command to enter the parent directory. If your version does not have this function, add the following code to. bashrc.
Alias... = "cd .."
You can also define .... To go to the top two directories.
If you want to learn the latest skills, please pay attention to the public number "Engineer's affairs"