Emanuel Sprosec


Basic commands

Show working directory

  pwd

Change directory

  cd ..    #change to superior directory
  cd    #change to home
  cd -    #change to last directory
  cd /abc    #change to abc directory

List files and directories

  ls    #list all
  -a    #show also hidden files
  -l    #show more details
  -t    #sort by modifications time

File type

  file abc    #filetype 

Create directories

  mkdir abc    #create directory
  mkdir abc abc2    #create two directories

Delete directories & files

  rmdir abc    #remove directory
  rm abc    #remove file
  rm -f *.txt   #remove all textfiles without confirmation
  rm -rf    #remove all files and subfiles and directories

Copy files

  cp
  cp -R    #Recursiv with subfiles and directories
  cp -R abc /targetdirectory
  cp *.txt  /targetdirectory

Move files

  mv abc.txt ~/abc    #move file to directory
  mv -f    #overwrite files without confirmation

Show content of text files

  cat abc.txt    #show content of file
  more abc.txt    #show content with pagination
  less abc.txt    #show pagination with go back
  cat abc.txt | less    #pipe commands

Combine files

  cat abc1 abc2 > abc12  #combine two files in one new files
  cat *txt | less   #Show content of all files

Count content

  wc -c -l -w    #Symbols, lines, words
  wc -l *.txt    #Show linecount
  wc *.txt    #Count of lines, words, symbols

Search content

  fgrep    #search exact
  grep     #search pattern
  fgrep kitty *.txt   #search kitty in txt files
  -i -l -L- V    #small/big letters, only name of files, name files without hit, show lines without hit
  grep -i '^abc.*[0-9].*,m$' *.txt    #search begin of all files with start "abc", minimum 1 number and end with m
  grep 'A.*Miau' /abc/kitty     #search lines start with A and end with Miau
  grep 'Kit[td]y' /abc/kitty    #search lines contain Kitty or Kitdy
  egrep -l 'Kitty|Miau' *.txt    #search all textfiles containing Kitty or Miau
  grep --ignore-case --line-number theword abc.csv > output.txt     #save result in file

Find files

  find ~/abc -name kitty.txt    #search file
  find ~/abc -name kitty.* -o -name miau.*     #search kitty or miau files

Zip files

  zip kitty.zip abc1 abc2

zip both files in kitty.zip

  zip -r kitty.zip  abc

zip directory abc

  unzip -v kitty.zip

list files in zip files

  unzip kitty.zip

unzip it


Start · Edit · Changes
Last update: 29.04.2023