LINUX / FILES & DIRECTORIES

Files & directories

Commands for navigating, creating, copying, moving and removing things in the filesystem.

pwd

Print the current working directory.

Description

Displays the absolute path of the directory you are currently working in.

Useful flags

-L Use the logical path, including symbolic links.
-P Use the physical path and resolve symbolic links.

Example

$ pwd
/var/www/project
ls

List files and directories.

Description

Displays the contents of a directory. Hidden files are omitted unless requested.

Useful flags

-l Long format; show permissions, owner, size and timestamps.
-a Include hidden files.
-h Display sizes in human-readable form.
-t Sort by modification time.

Example

$ ls -lah
total 24K
drwxr-xr-x  4 user user 4.0K Aug 26 10:32 .
drwxr-xr-x 12 user user 4.0K Aug 26 09:14 ..
-rw-r--r--  1 user user  842 Aug 26 10:31 notes.txt
-rwxr-xr-x  1 user user 1.2K Aug 25 18:07 deploy.sh
drwxr-xr-x  2 user user 4.0K Aug 25 17:42 scripts
cd

Change the current working directory.

Description

Moves the shell into another directory.

Useful flags

~ Refers to your home directory. Using just cd gives the same effect.
/ Refers to the root directory.
- Return to the previous directory.

Example

$ cd /var/www/project
$ pwd
/var/www/project
$ cd -
$ pwd
/home/user
ADD_COMMAND_NAME

Add command function.

Description

Add command's description.

Useful flags

FLAG Flag's description

Example

$ ADD EXAMPLES