Basic Commands
and Simple Shell Scripts72
Some shortcuts for directories include the following
: This is the home of the current user .: This is the current directory ..: This is the parent directory -: This is the directory used previously.
More details on managing files and directories in Linux and RHEL are available in the Listing,
creating, copying, and moving files,
directories, links, and hard links section.
Bash auto-completeShortcuts area faster way to reach commonly used directories or relative references to the current working directory. However, bash includes some capabilities to reach other directories in a fast way,
which is called auto-completion. It relies on the Tab key (the one with two opposing arrows at the very left of your keyboard, right above Caps Lock).
When reaching a folder or a file, we can hit Tab to complete its name. For example, if we want to go to the /etc/NetworkManager folder, we type the following:
[user@rhel-instance
]$ cd /etThen,
when we hit the Tab key, this will auto-complete it to etc, even adding the final forward slash (/), as it is a directory:
[user@rhel-instance
]$ cd /etc/Now, we type in the first letter of the directory we want to go to, NetworkManager, which is N:
[user@rhel-instance
]$ cd /etc/NThen, when we hit the Tab key, this will auto-complete it to /etc/NetworkManager/:
[user@rhel-instance
]# cd /etc/NetworkManager/Now, we can hit Enter and go there.
If we press Tab + Tab (pressing
Tab twice during complete, this will show a list of available targets to complete – for example, seethe following:
[user@rhel-instance
]# cd /rroot/ run Using the command line,
environment variables, and navigating through the filesystem
73
It can also be used to complete commands. We can type a letter, for example, h, hit Tab + Tab, and this will show all the commands starting with h:
Share with your friends: