May 4, 2013

Survival tips for biologists to navigate on linux

As a biologist I noticed that there are few resources that teach programming or linux commands from the biologists view. Here, I try to summarize the basic linux commands needed to navigate the linux folder structure, getting help and other basic tasks. This information given below will be just enough for survival. For detailed learning you may refer to other sources available on internet.

Basic linux tasks and related command for survival (commands are writtien in brackets):
1. Getting help on any command (man)
## get help on any command in linux
> man command
2. Creating directories (mkdir)
## create a directory
> mkdir name_of_new_directory
# for help on creating a directory
> man mkdir
3. Changing directories (cd)
## change directory
> cd /location/of/the/directory
# change to home directory
> cd
# change to one higher level directory
> cd ..
# change to second higher level directory
> cd ../..
# for help of changing directories
> man cd
4. Removing file/s or directory (rm)
## rm a file or directory
> rm name_of_file(s)_to_remove
# remove a directory
> rm -r name_of_folder(s)
# remove all files inside a directory without asking confirmation
> rm -rf name_of_folder(s)
# for help on removing files/folders
> man rm
5. Copying file/s or directory (cp)
## copy file(s) or directory(s)
> cp /old/location/of/file(s) /new/location/of/the/same/file(s)
# copy a directory to a new location
> cp -r /old/location/of/directory /new/location/of/the/same/directory
# copy the files elsewhere into the present directory
> cp /location/of/file .
# for help on copying
> man cp
6. Move the location of file/s or directory (mv)
## move a file or directory
mv /old/location/of/file /new/location/of/the/same/file
# mv a directory to a new location
> mv -r /old/location/of/directory /new/location/of/the/same/directory
# mv the files elsewhere into the present directory
> mv /location/of/file .
# for help on moving
> man mv
7. Rename a file or list of file/s (rename)
## rename a file or files
> rename old_file_name new_file_name
# rename a list of files with some common name to some other common name
# for example there are files "abc12, abc23, abc34" and we want to name them "xyz12, xyz23, xyz34"
> rename 's/abc/xyz/g' abc*
# for help on renaming
> man rename