0% found this document useful (0 votes)
14 views2 pages

Bash Cheat Sheet Level1

Bash_cheat_sheet

Uploaded by

mysmccded
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Bash Cheat Sheet Level1

Bash_cheat_sheet

Uploaded by

mysmccded
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

BASH cheat sheet - Level 1 ls

 dir     Directory   listing.   Use   the   –l   option   to   head  –N  file  


      list  in  long  format.   Display  the  N  first  lines  of  file(s).  Without  any  option  10  
  first  lines  are  displayed.  
File and directory handling commands chmod  who=permission  file    
Change   the   who   permission   of   file   to   permission.   Who   tail  –N  file  
cd  dir     change  directory  to  dir   can   be   u,g   or/and   o   (user,   group   or/and   other)   and   Display  the  N  last  lines  of  file(s).  Without  any  option  the  
cd  –     Go  back  to  the  previous  directory   permission  can  be  -­‐,x,w  or/and  r.   10  last  lines  are  displayed.  
cd  ..       Go  to  the  parent  directory     chmod  OctalOctalOctal  file    
cd    Go  to  the  user’s  home  directory    (same   Change  the  user,  group  and  other  permissions  as   command  >  file  
as  cd  ~  or  cd  /home/user/)   defined  by  each  octal.   Redirect  command  output  into  a  file.  If  the  file  exists,  it  
  • 4   read     (r)   is  overwritten.  
pwd     Show  the  current  durectory   • 2   write     (w)    
  • 1   execute    (x)   command  >>  file  
cp  file1  file2   Copy  file1  to  file2.  Use  –r  option  for   • 0   none     (-­‐)   Redirect  command  output  and  append  into  file.  
copying  a  directory.   chmod  754  file    
  Read,write,execute  for  user,  read  and  execute   cut  –d’;’  -­‐f1,4  file  
scp  source_file  target_  file   for  group  and  read  only  for  other.   Cut   out   selected   portions   of   each   line   of   a   file.   The   –d  
Secure   copy   over   a   network   connection.   A   remote   chmod  ug=rwx  file   option   defines   the   field   delimiter   character   (here  ;)  
source   or/and   target   must   follow   that   syntax:   Read,  write,  execute  for  user  and  group.   instead   of   the   default   tab   character.   The   –f   option  
user@IP:/home/user/path.  Use  –r  option  for  copying     specifies   the   field(s)   displayed   (here   the   first   and   the  
a  directory.   tar  czf  file.tar.gz  dir   Create   a   tar   with   Gzip   fourth).  
  compression  of  dir.      
rsync  –L  source_file  target_  file   tar  xzf  file.tar.gz     Extract  a  tar  using  Gzip.   sort  file  
Remote   file   copy.   Transfer   just   the   differences   between     Sort   lines   of   text   file   alphabetically.   Use   –n   option   to  
two   sets   of   files.   –L   option   transform   symlink   into   gzip  file    Compress  file  and  rename  it  to  file.gz.   take  into  account  the  numbers  (ascending  order).  Use    
referent  file/dir.   Use  the  –d  option  to  decompress   -­‐k  N  option  to  specified  to  sort  according  to  the  field  N.  
  file.gz  back  to  file.    
mv  file1  file2   Rename  or  move  file1  to  file2  if  file2  is   uniq  file  
an  existing  directory,  moves  file1  into   Filter  out  consecutive  repeated  lines  in  file.  –u  displays  
directory  file2.  
File information handling commands only  not  repeated  lines  while  -­‐d  displays  only  repeated  
mkdir  dir     Create  a  directory  dir.   ones.  
  wc  –l  file    Display  the  number  of  lines  file.  (-­‐w    
rm  file    Delete  file.  Use  –r  option  for  a   for  the  number  of  words,  -­‐c  for  the   split  –lN  file  prefix  
directory.   number  of  characters).  wc  without   Split  file  into  pieces  of  N  lines  labelled  by  prefix.  
ln  –s  file  link   Create  symbolic  link  link  to  file.   option  gives  these  three  information.   split  –b  Nm  file  
    Split   file   into   pieces   of   N   megabytes.   Use   k  
unlink  link     Remove  a  link.   cat  file     Display  the  content  of  file(s).   instead  of  m  for  kylobyte  and  none  for  byte.  
     
df    Show  disk  space  usage  (byte).  To  symplify  the   more  file    Display  the  content  of  file  one  screen   grep  "pattern"  file  
lecture  use  the  –h  option  (human  readable).   at  a  time.   Print   lines   of   file   that   match   the   pattern.   Use   the   –E  
du  –h  dir     Show  directory  space  usage.   less  file    Similar  as  more  but  allows  backward   option  to  interpret  the  pattern  as  a  regular  expression  
  and  forward  movement.   (see  Level  2  for  regular  expression).  
 
    man  command  :  display  the  command’s  manual  page  
Jacques  Dainat  -­‐  2015  
fold  –w  60  file   Break  the  lines  to  have  a  maximum  of  
60  columns  width  (80  by  default).  

Miscellaneous

history   Display  the  history  list  with  line  numbers.  


 
which  command   Locate  a  command.  
 
ssh  user@IP   Log  into  a  remote  machine.  
 
find  path  -­‐name  name*      
Find  in  path  and  sub-­‐directory  recurcively  the  
files  or  directories  matching  name.  
rev  file   Reverse  the  order  of  characters  in  every  line  of  
file.  
join    file1  file2    
Join   specified   files   based   on   join-­‐field   and  
writes   the   result   to   the   standard   output.   By  
default  join  works  on  the  first  field.  
join  -­‐1  2  -­‐2  2  –a1  –a2  –o  list–e  "value"  file1  file2  
-­‐1  2  and  -­‐2  2  allows  to  respectively  join  on  the  
second   field   of   file1   and   the   second   field   of  
file2.  
-­‐a1   and  –a2  option  allows  respectively  to  also  
include   the   non   matching   records   from   file1  
and   file2.   -­‐o   list   specify   the   fields   that   will   be  
output.   e.g  the   list   0,1.1,2.1   will   display  
respectively   the   join   field,   the   field1   of   file1  
and  the  field1  of  file2.  When  –o  option  is  used,  
the  –e   ‘value’  option  replace  any  missing  data  
fields  by  value.  
/  !\   Files  must  be  sorted  by  the  field  they  will  
be  joined  to  work  properly.  

File editing

vi  
vim     Vi  Improved  
nano  
emacs  

    man  command  :  display  the  command’s  manual  page  


Jacques  Dainat  -­‐  2015  

You might also like