Petter Holt Juliussen • Mail | GitHub | Letterboxd

for later reference.

Command reference

2019-04-04

Shell builtins

cd - change directory

Change the shell working directory.

cd [-L|[-P [-e]] [-@]] [dir]
cd /usr/bin # Change to absolute path
cd # Change working directory to home directory
cd ~ # Change working directory to home directory
cd ~user_name # Change working directory to the home directory of the specified user
cd . # Change to working directory
cd .. # Change to parent directory
cd - # Change to previous working directory

Commands

cp - copy files and directories

Make the directory(ies), if they do not already exist.

cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
    -R, -r, --recursive # copy directories recursively
    -i, --interactive # prompt before overwrite (overrides a previous -n option)
cp file1 file2      # Copies the contents of file1 into file2. If file2 does not exist, it is 
                    # created; otherwise, file2 is silently overwritten with the contents of file1.
cp -i file1 file2   # The user is prompted ("-i" = interactive) before file2 is overwritten (if it exists) 
                    # with the contents of file1.
cp file1 dir1       # Copy the contents of file1 (into a file named file1) inside of directory dir1.
cp -R dir1 dir2     # Copy the contents of the directory dir1. If directory dir2 does not exist, it is created. 
                    # Otherwise, it creates a directory named dir1 within directory dir2.
mkdir - make directory

Make the directory(ies), if they do not already exist.

mkdir [OPTION]... DIRECTORY...
    -p, --parents # no error if existing, make parent directories as needed
rm - remove

Remove files or directories.

rm [OPTION]... FILE...
    -r, -R, --recursive # remove directories and their contents recursively
    -f, --force # ignore nonexistent files, never prompt
pwd - print working directory

Print the full filename of the current working directory to the standard output.

pwd [OPTION]...
    -L, --logical # use PWD from environment, even if it contains symlinks
    -P, --physical # avoid all symlinks
find - search files

Find searches the directory tree rooted at each given file name by evaluating the given expression from left to right, according to the rules of precedence (see section OPERATORS), until the outcome is known (the left hand side is false for and operations, true for or), at which point find moves on to the next file name.

find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]
find /home/username/ -name "*.err"
cat - concatenate files

Concatenate FILE(s), or standard input, to standard output.

cat [OPTION]... [FILE]...