Essential Bash Commands and Their Usage

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/89

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

90 Terms

1
New cards

pwd

Report the path for the present working directory (current directory).

2
New cards

ls

List files in the current directory. Usage: ls or ls path

3
New cards

ls -l

Long listing, with information about size, permissions, ownership, etc.

4
New cards

ls -a

List all files, including those that start with a dot (which would normally be hidden).

5
New cards

ls -A

List all files, including those that start with a dot, excluding the implied '.' and '..'.

6
New cards

ls -R

Recursively list all files in subdirectories.

7
New cards

ls -r

List all entries in reverse order.

8
New cards

ls -S

List all entries and sort them by size ascending.

9
New cards

ls -t

List all entries and sort them by modification time ascending.

10
New cards

ls -F

Put a character at the end of filename to indicate its type.

11
New cards

ls -1

List all entries, one entry per line.

12
New cards

cd

Change current directory. Usage: cd path

13
New cards

mkdir

Make a directory. Usage: mkdir path

14
New cards

rm

Remove files and directories. Usage: rm path

15
New cards

rm -r

Recursively remove files and directories.

16
New cards

rm -i

Interactive mode, prompt before removing files.

17
New cards

rm --

Interpret all subsequent parameters as file names rather than options.

18
New cards

cp

Copy one or more files. Usage: cp old file new file or cp file1 file2 ... directory

19
New cards

cp -r

Recursively copy directories.

20
New cards

cp -a

Copies entries preserving links, preserving file attributes if possible, and copies directories recursively.

21
New cards

cp -u

Copies entries, replacing an existing entry only if the source is newer.

22
New cards

mv

Move files to new filenames or new directories. Usage: mv old name new name or cp file directory

23
New cards

mv -f

Removes existing destination files and never prompt the user.

24
New cards

mv -i

Interactive mode, prompt before overwriting anything.

25
New cards

cat

Read one or more files and write them out one after another to standard output.

26
New cards

cat -b

Output file contents, preceding each non-blank line with the corresponding line number.

27
New cards

cat -n

Output file contents, preceding each line with the corresponding line number.

28
New cards

who

Report who is logged in.

29
New cards

exit

Tell your shell to exit (logging you out of a telnet or secure shell connection).

30
New cards

finger

Give information about a user. Usage: finger username

31
New cards

date

Report what time the system thinks it is.

32
New cards

more

Display the contents of a file to the user one page at a time.

33
New cards

less

Like more but better.

34
New cards

less

Usage: less file

35
New cards

man

Provide online documentation for Unix commands, system calls, configuration files and other features. Usage: man command name

36
New cards

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.

37
New cards

man -k words

Look for man pages about the given keywords

38
New cards

head

Print the first ten lines of each file parameter (or from stdin if no parameter is given). Usage: head file

39
New cards

head -n num

Print the first num lines of the file.

40
New cards

tail

Print the last ten lines of each file parameter (or from stdin if no parameter is given). Usage: tail file

41
New cards

tail -n num

Print the last num lines of the file.

42
New cards

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

43
New cards

ps

Show currently running processes.

44
New cards

ps -e

Report on every process.

45
New cards

ps -H

Give hierarchical listing of parent/child processes.

46
New cards

ps -l

Give a long listing.

47
New cards

top

Like ps, but give a continuously updating report.

48
New cards

jobs

Show all processes that your shell is keeping up with along with their job numbers (shell builtin).

49
New cards

bg

Move a suspended process into the background (shell builtin). Usage: bg job number

50
New cards

fg

Move a backgrounded or suspended job to the foreground (shell builtin). Usage: fg job number

51
New cards

kill

Send a signal to a process asking it to terminate. Usage: kill process id

52
New cards

killall

Kill all processes running a given command. Usage: killall command name

53
New cards

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"

54
New cards

echo -n

Don't automatically print a newline at the end of the output.

55
New cards

env

Report exported environment variables.

56
New cards

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

57
New cards

grep -v

Report only lines that don't match the given pattern.

58
New cards

grep -c

Don't report matching lines, just print the number of lines that match in each input file.

59
New cards

grep -E

Interpret pattern as extended regular expression syntax.

60
New cards

grep -i

Ignore case.

61
New cards

grep -n

Prefix each reported match with the line number.

62
New cards

grep -q

Quiet mode. Don't print anything. Just use the exit status to report whether or not a match was found.

63
New cards

grep -o

Show only the part of a matching line that matches PATTERN.

64
New cards

find

Recursively search directories to find matching files. By default, just print out matching pathnames. Usage: find path options

65
New cards

find -print

Print out each matching path.

66
New cards

find -type f

Only report matching files.

67
New cards

find -type d

Only report matching directories.

68
New cards

find -mmin -n

Report files modified less than n minutes ago.

69
New cards

find -mmin +n

Report files modified more than n minutes ago.

70
New cards

find -mtime -n

Report files modified less than n days ago.

71
New cards

find -mtime +n

Report files modified more than n days ago.

72
New cards

find -exec command ;

Execute command for each matching file.

73
New cards

stat

Display information about files. Usage: stat options file

74
New cards

stat -c '%s'

Report size in bytes.

75
New cards

stat -c '%U'

Report name of the owner.

76
New cards

stat -c '%G'

Report group ownership of the file.

77
New cards

sort

Sort lines of given file (or stdin) and output them in sorted order. Usage: sort file

78
New cards

sort -n

Interpret each line as a number and sort by magnitude.

79
New cards

sort -r

Sort in reverse order.

80
New cards

wc

Report the number of bytes, words and lines in a file.

81
New cards

wc -c

Just report number of bytes.

82
New cards

wc -w

Just report the number of words.

83
New cards

wc -l

Just report the number of lines.

84
New cards

chmod

Change the permissions on a file or directory. Usage: chmod options file

85
New cards

chmod +x

Add execute permissions.

86
New cards

chmod -w

Remove wrte permissions.

87
New cards

chmod u+w

Add write permissions for the user that owns the file.

88
New cards

chmod g+r

Add read permissions for the group that owns the file.

89
New cards

chmod o-x

Remove execute permissions for others (other than the file's owner or group).

90
New cards

chmod a+r

Add read permissions for everyone.