Linux Flashcards
(41 cards)
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.
which
NAME
which – locate a program file in the user’s path
SYNOPSIS
which [-as] program …
DESCRIPTION
The which utility takes a list of command names and searches the path for each executable file that would be run had these commands actually been invoked.
curl
NAME
curl - transfer a URL
SYNOPSIS
curl [options] [URL…]
DESCRIPTION
curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.
curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. As you will see below, the number of features will make your head spin!
curl is powered by libcurl for all transfer-related features. See libcurl(3)
for details.
Ctrl + R ( bck-i-search)
Lets you search interactively through your previous commands, and then optionally edit the result before executing.
grep
NAME
grep, egrep, fgrep, zgrep, zegrep, zfgrep – file pattern searcher
SYNOPSIS
grep [-abcdDEFGHhIiJLlmnOopqRSsUVvwxZ] [-A num] [-B num] [-C[num]] [-e pattern] [-f file] [–binary-files=value] [–color[=when]] [–colour[=when]] [–context[=num]] [–label] [–line-buffered] [–null] [pattern] [file …]
DESCRIPTION
The grep utility searches any given input files, selecting lines that match one or more patterns. By default, a pattern matches an input line if the regular expression (RE) in the pattern matches the input line without its trailing newline. An empty expression matches every line. Each input line that matches at least one of the patterns is written to the standard output.
head
NAME
head – display first lines of a file
SYNOPSIS
head [-n count | -c bytes] [file …]
DESCRIPTION
This filter displays the first count lines or bytes of each of the specified files, or of the standard input if no files are specified. If count is omitted it defaults to 10.
If more than a single file is specified, each file is preceded by a header consisting of the string ``==> XXX
tail
NAME
tail – display the last part of a file
SYNOPSIS
tail [-F | -f | -r] [-q] [-b number | -c number | -n number] [file …]
DESCRIPTION
The tail utility displays the contents of file or, by default, its standard input, to the standard output.
The display begins at a byte, line or 512-byte block location in the input. Numbers having a leading plus (+') sign are relative to the beginning of the input, for example,
-c +2'' starts the display at the second byte of the input. Numbers having a leading minus (
-‘) sign or no explicit sign are relative to the end of the input, for example, -n 2'' displays the last two lines of the input. The default starting location is
-n 10’’, or the last 10 lines of the input.
wc
NAME
wc – word, line, character, and byte count
SYNOPSIS
wc [-clmw] [file …]
DESCRIPTION
The wc utility displays the number of lines, words, and bytes contained in each input file, or standard input (if no file is specified) to the standard output. A line is defined as a string of characters delimited by a character.
Characters beyond the final character will not be included in the line count.
A word is defined as a string of characters delimited by white space characters. White space characters are the set of characters for which the iswspace(3) function returns true. If more than one input file is specified, a line of cumulative counts for all the files is displayed on a separate line after the output for the last file.
od
NAME
od – octal, decimal, hex, ASCII dump
SYNOPSIS
od [-aBbcDdeFfHhIiLlOosvXx] [-A base] [-j skip] [-N length] [-t type] [[+]offset[.][Bb]] [file …]
DESCRIPTION
The od utility is a filter which displays the specified files, or standard input if no files are specified, in a user specified format.