1/89
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
pwd
Report the path for the present working directory (current directory).
ls
List files in the current directory. Usage: ls or ls path
ls -l
Long listing, with information about size, permissions, ownership, etc.
ls -a
List all files, including those that start with a dot (which would normally be hidden).
ls -A
List all files, including those that start with a dot, excluding the implied '.' and '..'.
ls -R
Recursively list all files in subdirectories.
ls -r
List all entries in reverse order.
ls -S
List all entries and sort them by size ascending.
ls -t
List all entries and sort them by modification time ascending.
ls -F
Put a character at the end of filename to indicate its type.
ls -1
List all entries, one entry per line.
cd
Change current directory. Usage: cd path
mkdir
Make a directory. Usage: mkdir path
rm
Remove files and directories. Usage: rm path
rm -r
Recursively remove files and directories.
rm -i
Interactive mode, prompt before removing files.
rm --
Interpret all subsequent parameters as file names rather than options.
cp
Copy one or more files. Usage: cp old file new file or cp file1 file2 ... directory
cp -r
Recursively copy directories.
cp -a
Copies entries preserving links, preserving file attributes if possible, and copies directories recursively.
cp -u
Copies entries, replacing an existing entry only if the source is newer.
mv
Move files to new filenames or new directories. Usage: mv old name new name or cp file directory
mv -f
Removes existing destination files and never prompt the user.
mv -i
Interactive mode, prompt before overwriting anything.
cat
Read one or more files and write them out one after another to standard output.
cat -b
Output file contents, preceding each non-blank line with the corresponding line number.
cat -n
Output file contents, preceding each line with the corresponding line number.
who
Report who is logged in.
exit
Tell your shell to exit (logging you out of a telnet or secure shell connection).
finger
Give information about a user. Usage: finger username
date
Report what time the system thinks it is.
more
Display the contents of a file to the user one page at a time.
less
Like more but better.
less
Usage: less file
man
Provide online documentation for Unix commands, system calls, configuration files and other features. Usage: man command name
man -S n
Look for documentation in section n of the manual. Section 1 is for shell commands, section 2 is for system calls and section 3 is for other functions.
man -k words
Look for man pages about the given keywords
head
Print the first ten lines of each file parameter (or from stdin if no parameter is given). Usage: head file
head -n num
Print the first num lines of the file.
tail
Print the last ten lines of each file parameter (or from stdin if no parameter is given). Usage: tail file
tail -n num
Print the last num lines of the file.
touch
Bring the modification time of a file up to the current time. Also, create an empty file if it doesn't already exist. Usage: touch file
ps
Show currently running processes.
ps -e
Report on every process.
ps -H
Give hierarchical listing of parent/child processes.
ps -l
Give a long listing.
top
Like ps, but give a continuously updating report.
jobs
Show all processes that your shell is keeping up with along with their job numbers (shell builtin).
bg
Move a suspended process into the background (shell builtin). Usage: bg job number
fg
Move a backgrounded or suspended job to the foreground (shell builtin). Usage: fg job number
kill
Send a signal to a process asking it to terminate. Usage: kill process id
killall
Kill all processes running a given command. Usage: killall command name
echo
Just print out its string parameters. Often used with variable expansion to generate output from a shell script. Example: echo "My home is $HOME"
echo -n
Don't automatically print a newline at the end of the output.
env
Report exported environment variables.
grep
Read from files listed on the command line (or stdin) and report lines that match a given pattern. Usage: grep pattern file1 file2 ... Example: grep "printf" test.h test.c
grep -v
Report only lines that don't match the given pattern.
grep -c
Don't report matching lines, just print the number of lines that match in each input file.
grep -E
Interpret pattern as extended regular expression syntax.
grep -i
Ignore case.
grep -n
Prefix each reported match with the line number.
grep -q
Quiet mode. Don't print anything. Just use the exit status to report whether or not a match was found.
grep -o
Show only the part of a matching line that matches PATTERN.
find
Recursively search directories to find matching files. By default, just print out matching pathnames. Usage: find path options
find -print
Print out each matching path.
find -type f
Only report matching files.
find -type d
Only report matching directories.
find -mmin -n
Report files modified less than n minutes ago.
find -mmin +n
Report files modified more than n minutes ago.
find -mtime -n
Report files modified less than n days ago.
find -mtime +n
Report files modified more than n days ago.
find -exec command ;
Execute command for each matching file.
stat
Display information about files. Usage: stat options file
stat -c '%s'
Report size in bytes.
stat -c '%U'
Report name of the owner.
stat -c '%G'
Report group ownership of the file.
sort
Sort lines of given file (or stdin) and output them in sorted order. Usage: sort file
sort -n
Interpret each line as a number and sort by magnitude.
sort -r
Sort in reverse order.
wc
Report the number of bytes, words and lines in a file.
wc -c
Just report number of bytes.
wc -w
Just report the number of words.
wc -l
Just report the number of lines.
chmod
Change the permissions on a file or directory. Usage: chmod options file
chmod +x
Add execute permissions.
chmod -w
Remove wrte permissions.
chmod u+w
Add write permissions for the user that owns the file.
chmod g+r
Add read permissions for the group that owns the file.
chmod o-x
Remove execute permissions for others (other than the file's owner or group).
chmod a+r
Add read permissions for everyone.