




command -options argument. For example, ls -l Documents would list the contents of the Documents directory in a detailed long format.pwd — Print current directory pathls — List files and directories; options: -l (detailed), -a (all files including hidden)cd — Change directory; special shortcuts: .. (up one level), ~ (home directory)--help option to display usage information, e.g., ls --helpcd /mnt/c/Users/hp/Downloads
/ (slash). This root is the top-most directory from which all other directories branch.pwd command:pwd
/home/ubuntu/home/ubuntu, indicates your home directory, which is your default location when opening a new terminal. "Ubuntu" in this case is the username./ at the start denotes the root directoryhome is a folder within the root/ characters act as separators between foldersubuntu is the final folder in this specific path/ character has two meanings: it represents the root directory when at the beginning of a path, and it acts as a separator within a path.
MobaXterm_Personal_XX.X.exe.nano by typing apt install nano, then y twice.⌘ + space) and type "terminal" to launch.Ctrl + Alt + T.nano is installed by typing nano --version. If not, use sudo apt install nano.!echo "Hello from Colab!" (note the exclamation mark before the command). Press Ctrl + Enter to run. You should see "Hello from Colab!" as output.![Unix Command].ls (listing) command:ls
Documents Downloads Music Public
Desktop Movies Pictures Templates
cd ("change directory") command changes your current working directory. You can specify a directory using an absolute path (starting from the root /), or a relative path (relative to your current directory).cd /content/sample_data/pwd. To move up one directory (to the parent directory), use ..:cd ..~ (tilde) at the start of a path as your user's home directory (e.g., /home/ubuntu), making it a quick shortcut to return home.
/tmp and type:ls sample_dals /content/sample_data/
mkdir my_project
cd my_project
touch report.txt
cp report.txt final_report.txt
mv final_report.txt /content/sample_data/bioinformatics_day1
rm report.txt
ls to see what it contains:cd /content/sample_data/
ls
anscombe.json mnist_test.csv mnist_train_small.csv
california_housing_test.csv README.md
california_housing_train.csvthesis_notes using the mkdir ("make directory") command :mkdir bioinformatics_day1ls:lsanscombe.json mnist_test.csv
bioinformatics_day1 mnist_train_small.csv
california_housing_test.csv README.md
california_housing_train.csv
mkdir command is your primary tool for creating organized directory structures. You can also create nested directories using the -p flag: mkdir -p parent/child/grandchild
README.txt, which indicates this is a plain text file.
things.txt, which contains a note of books to read for our thesis. Let's move this file to the thesis_notes directory we created earlier, using the mv ("move") command:touch things
mkdir thesis_notes
mv things.txt thesis_notes/
mv what we're "moving", while the second is where it's to go. In this case, we're moving things.txt to thesis_notes/. We can check the file has moved there:ls thesis_notes
things.txtmv command to change a file's name. Here's how we would do it:mv thesis_notes/things.txt thesis_notes/books.txtmv will silently overwrite any existing file with the same name, which could lead to data loss.mv also works with directories, and you can use it to move or rename an entire directory just as you use it to move an individual file.
rm ("remove"). For example, let's remove one of the files we copied earlier:mkdir backup
touch ref1.txt ref2.txt
rm backup/ref1.txt
ls backup/.rm backup
rm: cannot remove `backup': Is a directoryrm by default only works on files, not directories.rm command can remove a directory and all its contents if we use the recursive option -r, and it will do so without any confirmation prompts:rm -r backuprm -r should be used with great caution (you might consider adding the interactive option rm -r -i).rmdir command. This is a safer option than rm -r, because it will never delete the directory if it contains files, giving us a chance to check whether we really want to delete all its contents.
*, which is used to match zero or more characters.pentane.pdb and propane.pdb, because the 'p' at the front only matches filenames that begin with the letter 'p'?, which matches any character exactly once. For example:?ethane.pdb would only match methane.pdb (whereas *ethane.pdb matches both ethane.pdb and methane.pdb)???ane.pdb matches three characters followed by ane.pdb, giving cubane.pdb ethane.pdb octane.pdbls *.pdf in the molecules directory (which does not contain any PDF files) results in an error message that there is no file called *.pdf.
/home/amanda/data, which of the following commands could Amanda use to navigate to her home directory (/home/amanda)?cd .cd /cd /home/amandacd ../..cd ~cd homecd ~/data/..cdcd ..~ stands for the user's home directory, in this case /home/amanda

cat <file> — Display entire file contenthead <file> / tail <file> — Show first/last 10 lines by defaultmore <file> / less <file> — Paginate file content for easier readinggrep <pattern> <file> — Search for text patterns inside filesnano (simple and beginner-friendly) and the more powerful, advanced options like vim and emacs, which are staples for experienced users.cat command, which stands for "concatenate" (we will see why it's called this way in a little while):cd sample_data
cat california_housing_train.csvhead command:head california_housing_train.csv
head prints the first 10 lines of the file. We can change this using the -n option, followed by a number, for example:head -n 2 california_housing_train.csv
"longitude","latitude","housing_median_age","total_rooms","total_bedrooms","population","households","median_income","median_house_value"
-114.310000,34.190000,15.000000,5612.000000,1283.000000,1015.000000,472.000000,1.493600,66900.000000tail command:tail -n 2 california_housing_train.csv-124.300000,41.800000,19.000000,2672.000000,552.000000,1298.000000,478.000000,1.979700,85800.000000
-124.350000,40.540000,52.000000,1820.000000,300.000000,806.000000,270.000000,3.014700,94600.000000less command:less california_housing_train.csvless will open the file in a viewer where you can use ↑ and ↓ to move line-by-line or the Page Up and Page Down keys to move page-by-page. You can exit less by pressing Q (for "quit"). This will bring you back to the console.more command, allowing backward navigation through files.
wc (word count) command is a powerful tool for analyzing text files. It can count lines, words, and characters in one or more files.# Count lines, words, and characters in the sample file
!echo "Complete word count:"
!wc /content/sample_data/bioinformatics_day1/sample_data.txt
Complete word count:
10 44 282 /content/sample_data/bioinformatics_day1/sample_data.txt* wildcard to count lines, words, and characters (in that order, left-to-right) of all our PDB files. The output shows three columns: lines, words, and characters for each file, with a total at the bottom.
wc has options for all of them:# Count lines only
!echo "Line count only:"
!wc -l /content/sample_data/bioinformatics_day1/sample_data.txtLine count only:
10 /content/sample_data/bioinformatics_day1/sample_data.txt-l option is particularly useful when working with data files where each line represents a record or observation.
cat command stands for "concatenate". This is because this command can be used to concatenate (combine) several files together. For example, if we wanted to combine all PDB files into one:cat *.pdb
> operator.# List files and save to a file using >
!ls -l /content/sample_data/bioinformatics_day1/*.pdb > /content/sample_data/bioinformatics_day1/pdb_files.txt
!cat /content/sample_data/bioinformatics_day1/pdb_files.txt
ls.> operator will create a new file or overwrite an existing file. If you want to append to an existing file instead, use >>.

; — Sequential execution (run regardless of success)&& — Conditional success (run next only if previous succeeds)|| — Conditional failure (run next only if previous fails)| to pass the output of one command as input to another. For example, ls -l | grep ".txt" lists files and filters for text files.$1, $@ for script inputs, allowing your scripts to accept arguments and become more flexible* to match multiple characters in file names (e.g., rm *.log to delete all log files).sh files and run them with bash script.sh for reproducible workflows


cd ~/Desktop/data-shellsequencing directory named backup.
-r with the cp command (-r means "recursive").-r option, this is what happens:cp sequencing backup
cp: -r not specified; omitting directory 'sequencing'-r.cp -r sequencing backupls we can see a new folder called backup:ls
README.txt backup books_copy.txt coronavirus molecules sequencing thesis_notes-r (recursive) flag is essential when working with directories. It tells cp to copy the directory and all of its contents, including subdirectories.
cd ~/Desktop/data-shellcp do when given several filenames and a directory name?mkdir -p backup
cp molecules/cubane.pdb molecules/ethane.pdb backupcp do when given three or more file names?cp molecules/cubane.pdb molecules/ethane.pdb molecules/methane.pdb/
cp copies the files to the named directory. This is the standard way to copy multiple files at once.cp throws an error such as the one below, because it is expecting a directory name as the last argument:cp: target 'molecules/methane.pdb' is not a directorycp interprets the last argument as the destination, and in this case, it's a file, not a directory.cp with multiple source files, the last argument must be a directory where all the files will be copied.
ls command(s) will produce this output?ethane.pdb methane.pdbls *t*ane.pdbls *t?ne.*ls *t??ne.pdbls ethane.** wildcard matches zero or more characters, while ? matches exactly one character.
*) followed by the letter t, then zero or more characters (*) followed by ane.pdb. This gives ethane.pdb methane.pdb octane.pdb pentane.pdb.*) followed by the letter t, then a single character (?), then ne. followed by zero or more characters (*). This will give us octane.pdb and pentane.pdb but doesn't match anything which ends in thane.pdb.??) between t and ne. This correctly matches ethane.pdb and methane.pdb.ethane.pdb, missing methane.pdb.
sequencing and complete the following tasks:run1/ directory. Save the output in a file called sequencing_files.txt.ls run2 > sequencing_files.txt?>> can be used to append the output of a command to an existing file. Re-run both of the previous commands, but instead use the >> operator the second time. What happens now?> (overwrite) and >> (append)!
ls, followed by > to save the output in a file:ls run1 > sequencing_files.txtcat sequencing_files.txt
sampleA_1.fq.gz
sampleA_2.fq.gz
sampleB_1.fq.gz
sampleB_2.fq.gz
sampleC_1.fq.gz
sampleC_2.fq.gz
sampleD_1.fq.gz
sampleD_2.fq.gz> creates a new file and writes the command output to it.
ls run2/ > sequencing_files.txt, we will replace the content of the file:cat sequencing_files.txt
sampleE_1.fq.gz
sampleE_2.fq.gz
sampleF_1.fq.gz
sampleF_2.fq.gz> operator overwrites the existing file content. All previous data is lost. This is why it's crucial to understand the difference between > and >>!
>> operator the second time we run the command, we will append the output to the file instead of replacing it:ls run1/ > sequencing_files.txt
ls run2/ >> sequencing_files.txt
cat sequencing_files.txt
sampleA_1.fq.gz
sampleA_2.fq.gz
sampleB_1.fq.gz
sampleB_2.fq.gz
sampleC_1.fq.gz
sampleC_2.fq.gz
sampleD_1.fq.gz
sampleD_2.fq.gz
sampleE_1.fq.gz
sampleE_2.fq.gz
sampleF_1.fq.gz
sampleF_2.fq.gz>> operator preserved the original content and added the new content at the end.
coronavirus/variants/, there are several CSV files with information about SARS-CoV-2 virus samples that were classified according to clades (these are also commonly known as coronavirus variants).all_countries.csvalpha.csv that contains only the Alpha variant samples
cat to combine all the files into a single file:cat *_variants.csv > all_countries.csv*_variants.csv matches all CSV files ending with "_variants.csv", and the > operator saves the combined output to a new file.grep to find a pattern in our text file and use > to save the output in a new file:grep "Alpha" all_countries.csv > alpha.csvless alpha.csv.wc to count the lines of the newly created file:wc -l alpha.csv

