Questa è una vecchia versione del documento!


UNIX basic commands

Contents
  • Introduction
  • bash and tcsh shells
  • Working with directories
  • Environment variables
  • Editing text files
  • Other Web tutorials

http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/admin/

Familiarity with Linux is necessary

If you are not familiar with using Unix/GNU Linux this page is intended to provide a description of basic linux commands and references to more information.

When working in Linux, you will activate a terminal and inside the terminal shell will be running, i.e. a program interpreting your commands. Commands are typed inside this shell, and you press ENTER to issue them. For most commands, additional arguments can be issued by using minus signs (where \ signs are used in Windows), e.g. command -a - b -c or command -abc. To find out what options are available for a given command, and what those options do, type command –help, which works in most cases, or try to have a more detailed information with the man command.

Other useful links:

CMS WorkBook -

BaBar WorkBook

Command Description
man <command>
pwd
cd <dirName>
cd /path/to/directory
cd
cd ..
cd .
mkdir <dirName>
ls
ls -l
ls -althr
ls <dirName>
ls /path/to/dirName
mv <oldName> <newName>
mv <fileName> /path/to/newName
cp bla bla bla
rm <fileName>
acroread fileName.pdf
evince fileName.pdf

Set alias in ~/.cshrc file

alias ll 'ls -ahl'

or in a ~/.bashrc

alias ll='ls ahl'

Environment variables

export VarName=value     # sh and sh-like shells (e.g. bash)
setenv varName value     # csh and csh-like shells (e.g. tcsh)
set varName=value

NOTA! variabili settate con set sono viste solo dalla shell, con setenv/export anche dai programmi!

Find files

which <command>

e.g.

which cdsterm
/usr/local/bin/cdsterm
find /path/to/start/directory -name fileName
find 

Text editors

nano, vi, gedit, nedit

emacs,

emacs -nw <fileName>

Create a zipped file:

zip fileName.zip fileName

Extract a zipped file:

unzip fileName.zip

Create a gzipped file:

gzip fileName

Extract a gzipped file:

gunzip fileName.gz     [gzip -d fileName.gz]

Create a .tar.gz archive:

tar -czvf fileName.tar.gz /path/to/directory

Extract a .tar.gz archive:

tar -xzvf fileName.tar.gz

Create a .tar.bz2 archive:

tar -cjvf fileName.tar.bz2 /path/to/directory

Extract a .tar.bz2 archive:

tar -xjvf fileName.tar.bz2

Extract a .rar file:

unrar fileName.rar