A few tips about the cd command

=> Comment on Mastodon

While everyone familiar with a shell know about the command cd

there are a few tips you should know.

Moving to your $HOME directory

$ pwd

/tmp

$ cd

$ pwd

/home/solene

Using cd without argument will change your current directory to

your $HOME.

Moving into someone $HOME directory

While this should fail most of the time because people shouldn't allow

anyone to visit their $HOME, there are use case it can be used though.

$ cd ~user1

$ pwd

/home/user1

$ cd ~solene

$ pwd

/home/solene

Using ~user as a parameter will move to that user $HOME directory,

note that cd and cd ~youruser have the same result.

Moving to previous directory

This is a very useful command which allow going back and forth between

two directories.

$ pwd

/home/solene

$ cd /tmp

$ pwd

/tmp

$ cd -

/home/solene

$ pwd

/home/solene

When you use cd - the command will move to the previous directory

in which you were. There are two special variables in your shell:

Proxy Information
Original URL
gemini://perso.pw/blog//articles/cd-command.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
172.357879 milliseconds
Gemini-to-HTML Time
0.743429 milliseconds

This content has been proxied by September (3851b).