- Begin with
/
- Examples
/full/path/to/file
/home/kim/dev/hello-world.txt
- Do not begin with a
/
- Reference files or directories relative to the current directory
- Examples
relative/path/to/file
../relative/path/to/file
-../
- Reference the parent directory../../../relative/path/to/file
- Reference the parent of the parent of the parent directory
.
references the current directory- Examples
./some-file
- Reference the filesome-file
in the current directoryls .
- List the files in the current directory
../
references the parent directory- You can use multiples (
../../../
) to reference a directory multiple levels above - Examples
../some-file
- Reference the filesome-file
which exists one directory above the current directoryls ../../../
- List the contents of the directory three levels above the current directory
- What does it do?
- Change directory
- Examples
cd
- Change to home directorycd /full/path/to/dir
- Change to the specified directorycd relative/path/to/dir
cd ..
- Change to parent directorycd ../../../relative/path/to/dir
- Change to specified directory, with each../
indicating a parent directory
- What does it do?
- List the contents of a directory
- Does not inherently list hidden files
- Examples
ls
- List contents of current directoryls /full/path/to/dir
- List contents of specified directoryls relative/path/to/dir
ls -la
- List all contents of current directory (including hidden files) along with permission and ownership details
- What does it do?
- Create a new directory
- Examples
mkdir new-dir-name
- Make a new directory in current directorymkdir /full/path/to/new/dir
- Make a new directory at the specified locationmkdir relative/path/to/new/dir
- What does it do?
- Print full path to the current directory
- What does it do?
- Remove a file
- Note -
rm
permanently deletes files without sending them to trash first, so be careful!
- Examples
rm /full/path/to/file
- Remove specified filerm relative/path/to/file
rm ../../../relative/path/to/file
rm -r /full/path/to/dir
- Remove specified directory and all of its contents (files and subdirectories)rm -r relative/path/to/dir
- What does it do?
- Create a new file
- Examples
touch new-file-name
- Create a new file in current directorytouch /full/path/to/new/file
- Create a new file at the specified locationtouch relative/path/to/new/file
touch ../../../relative/path/to/new/file
grep
echo
which
- Subshells and
$()
- Permissions and
chmod
- Ownership and
chown
- Parameter expansion
- Shell variables
- Conditionals and
test
$PATH
~/.bash_profile
source
export
PYTHONPATH