git clone https://github.com/BioinformaticsOnLine/one-health-26cd one-health-26git statusgit pullls




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.

[username@master ~]$whoami to display your username, and hostname to check system information. If both respond correctly, you are ready to work!cd, list files with ls, and edit files with nano. To save and exit nano: press Ctrl + X → Y → Enter.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.ls (listing) command:ls
DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 LICENSE README.md requirements.txt
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 one-health-26/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.
ls onels one-health-26/
# Create our working directory
mkdir -p ~/bioinfo_day1
cd ~/bioinfo_day1 && pwd
# Create a subdirectory
mkdir ~/bioinfo_day1/thesis_notes
ls -l ~/bioinfo_day1/
# Create nested directories in one command
mkdir -p ~/bioinfo_day1/projects/experiment1
ls -l ~/bioinfo_day1/
ls to see what it contains:cd /one-health-26
ls
DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 LICENSE README.md requirements.txtthesis_notes using the mkdir ("make directory") command :# Create multiple empty files at once
cd ~/bioinfo_day1/thesis_notes
touch book1.txt book2.txt notes.txt references.txt
ls -l
# Write content to a file
echo "Chapter 1: Introduction" > book1.txt
echo "Chapter 2: Methods" >> book1.txt
cat book1.txt
# Write a multi-line file using heredoc
cat > sample_data.txt << 'EOF'
Line 1: Introduction to Unix
Line 2: Understanding File Systems
Line 3: Command Line Basics
Line 4: File Management
Line 5: Text Processing
Line 6: Advanced Scripting
Line 7: System Administration
Line 8: Networking Concepts
Line 9: Security Best Practices
Line 10: Advanced Topics
EOF
cat sample_data.txt
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
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:# Remove a single file
rm ~/bioinfo_day1/thesis_notes/archive_book1.txt
ls ~/bioinfo_day1/thesis_notes/
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:# Remove a directory
rm -r ~/bioinfo_day1/thesis_notes_backup
ls ~/bioinfo_day1/rm -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):# Print the whole file
cat ~/bioinfo_day1/thesis_notes/sample_data.txthead command:head ~/bioinfo_day1/thesis_notes/sample_data.txt
head prints the first 10 lines of the file. We can change this using the -n option, followed by a number, for example:# First 3 lines
echo "First 3 lines:"
head -n 3 ~/bioinfo_day1/thesis_notes/sample_data.txt
tail command:# Last 3 lines
echo "Last 3 lines:"
tail -n 3 ~/bioinfo_day1/thesis_notes/sample_data.txtless command:# Interactive viewer (best for large files)
less ~/bioinfo_day1/thesis_notes/sample_data.txtless 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.# Full count
echo "Complete word count:"
wc ~/bioinfo_day1/thesis_notes/sample_data.txt
Complete word count:
10 44 282 ~/bioinfo_day1/thesis_notes/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:# Lines only
wc -l ~/bioinfo_day1/thesis_notes/sample_data.txt
# Words only
wc -w ~/bioinfo_day1/thesis_notes/sample_data.txt
# Characters only
wc -c ~/bioinfo_day1/thesis_notes/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 ~/bioinfo_day1/variants1.csv \
~/bioinfo_day1/variants2.csv \
> ~/bioinfo_day1/all_variants.csv
> operator.# Save ls output to a file
ls ~/bioinfo_day1 > ~/bioinfo_day1/file_list.txt
cat ~/bioinfo_day1/file_list.txt
# Save wc output to a file
wc -l ~/bioinfo_day1/*.pdb > ~/bioinfo_day1/line_counts.txt
cat ~/bioinfo_day1/line_counts.txt
# Append txt file counts (does NOT overwrite)
wc -l ~/bioinfo_day1/*.txt >> ~/bioinfo_day1/line_counts.txt
cat ~/bioinfo_day1/line_counts.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 ~/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 ~/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

