As you may be aware, a Linux filesystem is in the form of a large tree with many branches called "subdirectories". When you issue a shell command, it is often necessary to know where you are in the "tree". Type this example:
$ pwd
/path/path/path
When you try this example ("pwd" means "print working directory"), your current working directory will be printed.
You can decide where you are in the tree. Type this example:
$ cd ~
$ pwd
/home/username
The symbol "~" is a special shortcut character that can be used to refer to your home directory. You could have typed this —
$ cd /home/username
— and accomplished the same result, but if you think about it, the "~" character is more portable. Later, when you are writing shell scripts, you might want a command that moves to any user's home directory.
$ pwd
/path/path/path
When you try this example ("pwd" means "print working directory"), your current working directory will be printed.
You can decide where you are in the tree. Type this example:
$ cd ~
$ pwd
/home/username
The symbol "~" is a special shortcut character that can be used to refer to your home directory. You could have typed this —
$ cd /home/username
— and accomplished the same result, but if you think about it, the "~" character is more portable. Later, when you are writing shell scripts, you might want a command that moves to any user's home directory.
No comments:
Post a Comment