-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_reference.qmd
73 lines (63 loc) · 2.83 KB
/
bash_reference.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
title: Bash reference
execute:
enabled: false
---
## Essential commands
Knowledge of these commands is required to pass both the exercises and exam.
- `cat`: show file contents on terminal
- `cd`: change directory
- `cd ~`: go to your home folder
- `cd ..`: go to parent folder
- `chmod`: change permissions
- `comm`: compare two sorted files line by line
- `comm -12`: only output lines common to both files
- `cp`: copy file/folder
- `du`: calculate file size
- `du -h`: display file size in a human-readable format
- `echo`: display a line of text
- `grep`: find a regular expression in a text file
- `grep -E`: use extended regular expressions
- `grep -v`: invert sense of matching, select non-matching lines
- `grep -o`: print only the matched part of a line
- `gunzip`: expand a file that has been compressed in GZ format; replaces the zipped file with the uncompressed file
- `gunzip -c`: write unzipped file contents to stdout (useful for piping)
- `head`: output the first lines of a file (by default, the first 10 lines)
- `head -5` or `head -n5`: print the first 5 lines
- `less`: display the contents of a file
- `ls`: list directory contents
- `ls -l`: use a long listing format, i.e., one file/folder per line with additional information (permissions, owner, size, date modified)
- `ls -a`: show all files/folders (i.e., even those starting with `.`)
- `man`: show the manual for a command
- `mkdir`: create folder
- `mkdir -p`: when creating nested folders, also create parent folders
- `mv`: move file/folder
- `nano`: edit a text file
- `passwd`: change password
- `pwd`: output the current working directory
- `sed`: filter and transform text
- `sed 's/foo/bar/g'`: substitute all occurrences of `foo` with `bar` ([details](bash.html#reformatting-the-ensembl-fasta-file))
- `sort`: sort lines in a text file
- `ssh user@host`: connect to a server `host` with user `user`
- `tail`: output the last lines of a file (by default, the last 10 lines)
- `tail -5` or `tail -n5`: print the last 5 lines
- `touch`: change file timestamp; create empty file if it does not exist
- `uniq`: omit repeated lines of text
- `wc`: print newline, word, and byte counts for each file
- `wc -l`: only print the number of lines
- `wget`: download a file
## Other commands
These commands are required for the exercises, but less important for the exam.
- `clear`: clear the terminal
- `gzip`: compress a file
- `md5sum`: calculate the MD5 checksum of a file
- `source`: run bash commands stored in a text file
- `tr`: translate or delete characters
- `tr -d`: delete character
- `zless`: scroll through a zipped file
## Important concepts
- [permissions](bash.html#permissions)
- [pipes](bash.html#pipes)
- [file pattern matches](bash.html#file-pattern-matches)
- [regular expressions](bash.html#simple-regular-expressions)
- [while loops](bash.html#loops)