Linux Flashcards
echo
The echo utility writes any specified operands, separated by single blank ( ') characters and followed by a newline (
\n’) character, to the standard output.
The following option is available:
-n
Do not print the trailing newline character. This may also be achieved by appending `\c’ to the end of the string, as is done by iBCS2 compatible systems.
Ctrl + E
Go to the end of current terminal line
Ctrl + A
Go to beginning of current terminal line
Ctrl + U
Erase current terminal line
clear (Ctrl + L)
clear clears your screen if this is possible. It looks in the environment for the terminal type and then in the terminfo database to figure out how to clear the screen.
exit (Ctrl + D)
Quits the terminal / command line
sleep
The sleep command suspends execution for a minimum of s seconds. If the sleep command receives a signal, it takes the standard action.
Example: $ sleep 60
cat
NAME
cat – concatenate and print files
SYNOPSIS
cat [-benstuv] [file …]
DESCRIPTION
The cat utility reads files sequentially, writing them to the standard output. The file operands are processed in command-line order. If file is a single dash (`-‘) or absent, cat reads from the standard input. If file is a UNIX domain socket, cat connects to it and then reads it until EOF.
> (redirect operator)
Takes the (string) output of the command left to the redirect operator (>) and redirects it into a file specified on the right side of the redirect operator.
diff
NAME
diff - compare files line by line
SYNOPSIS
diff [OPTION]… FILES
ls
NAME
ls – list directory contents
SYNOPSIS
ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file …]
DESCRIPTION
For each operand that names a file of a type other than directory, ls displays its name as well as any requested, associated information. For each operand that names a file of type directory, ls displays the names of files contained within that directory, as well as any requested, associated information.
If no operands are given, the contents of the current directory are displayed. If more than one operand is given, non-directory operands are displayed first; directory and non-directory operands are sorted separately and in lexicographical order.
touch
NAME
touch – change file access and modification times
SYNOPSIS
touch [-A [-][[hh]mm]SS] [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file …
DESCRIPTION
The touch utility sets the modification and access times of files. If any file does not exist, it is created with default permissions.
By default, touch changes both modification and access times. The -a and -m flags may be used to select the access time or the modification time individually. Selecting both is equivalent to the default. By default, the timestamps are set to the current time. The -t flag explicitly specifies a different time, and the -r flag specifies to set the times those of the specified file. The -A flag adjusts the values by a specified amount.
Quiz: How to list all files of a directory ordered by the modification time showing the ones that have been modified most recently at the bottom?
ls -rtl
mv
NAME
mv – move files
SYNOPSIS
mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source … directory
DESCRIPTION
In its first form, the mv utility renames the file named by the source operand to the destination path named by the target operand. This form is assumed when the last operand does not name an already existing directory.
In its second form, mv moves each file named by a source operand to a destination file in the existing directory named by the directory operand. The destination path for each operand is the pathname produced by the concatenation of
the last operand, a slash, and the final pathname component of the named file.
cp
NAME
cp – copy files
SYNOPSIS
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file … target_directory
DESCRIPTION
In the first synopsis form, the cp utility copies the contents of the source_file to the target_file. In the second synopsis form, the contents of each named source_file is copied to the destination target_directory. The names of the files themselves are not changed. If cp detects an attempt to copy a file to itself, the copy will fail.
rm
NAME
rm, unlink – remove directory entries
SYNOPSIS
rm [-dfiPRrvW] file …
unlink file
DESCRIPTION
The rm utility attempts to remove the non-directory type files specified on the command line. If the permissions of the file do not permit writing, and the standard input device is a terminal, the user is prompted (on the standard error output) for confirmation.