Module 1

The plan

Create directory and practice moving around

To create file and folders in linux is quite simple. You can use a number of programs for creating an empty file (touch) or an empty directory (mkdir)

touch my_beautiful_file.txt
mkdir my_beautiful_folder

To display the list of files and folder we can use the command ls

ls

my_beautiful_file.txt  my_beautiful_folder

To change the name of a file (or a directory) you can use the command mv while for copying the file you can use cp. Adding the option -r (recursive) to cp allows to copy a whole folder and its content.

mv my_beautiful_file.txt my_ugly_file.txt
mv my_beautiful_folder my_ugly_folder

cp my_ugly_file.txt my_beautiful_file.txt
cp my_ugly_folder -r my_beautiful_folder

If you omit the -r option the system will complain

cp my_ugly_folder my_other_folder

cp: omitting directory ‘my_ugly_folder’

You can use mv also for moving a file (or a directory) inside a folder. Also cp will allow you to make a copy inside a folder.

mv my_beautiful_file.txt my_beautiful_folder
cp my_ugly_file.txt my_ugly_folder

ls

my_beautiful_folder  my_ugly_file.txt  my_ugly_folder

For entering in a folder we can use the tool cd

cd my_ugly_folder

ls

my_ugly_file.txt

For going out we can move one level out

cd ../

ls

my_beautiful_folder  my_ugly_file.txt  my_ugly_folder

Sometimes we get lost and would like to know where we are. We can use the command pwd

We can write to a file using the character >, that means output redirection.

echo "ATGTACTGACTGCATGCATGCCATGCA" > my_dna.txt

And display the content of the file using the program cat

cat my_dna.txt

ATGTACTGACTGCATGCATGCCATGCA

To convert this sequence to a RNA one we can just replace the T base with U by using the program sed. The sintax of this program is the following s/<TO BE REPLACED>/<TO REPLACE>/.
You can add a g at the end if you want to replace every character found s/<TO BE REPLACED>/<TO REPLACE>/g.


sed s/T/U/g my_dna.txt > my_rna.txt

cat my_rna.txt

AUGUACUGACUGCAUGCAUGCCAUGCA

Every command has a manual, you can read it by using the program man with the name of the tool.

man ls

LS(1)                                                                   User Commands                                                                  LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List information about the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape
              print C-style escapes for nongraphic characters
 Manual page ls(1) line 1 (press h for help or q to quit)

Recap

Next Session

Download files from repositories