Jump to content

Linux cheat sheet #03


Administrator
 Share

Recommended Posts

  • Administrators

Basics

File Hierarchy Standard (FHS)

Path Content
/bin Binaries (User)
/boot Static boot loader files
/etc Host specific configs
/lib Shared libraries and kernel modules
/sbin Binaries (System/root)
/var Varying files (e.g. Logs)
/usr 3rd party software
/proc Pseudo file system
/sys Pseudo file system
/mnt Mountpoint for internal drives
/media Mountpoint for external drives
/home User homes
/run PID files of running processes

Commands

File System Commands

Command Param Description
cd - Navigate to last dir
  ~ Navigate to home
  ~username Navigate to home of specified user
pwd   Print working dir
ls   Print dir content
  -l Format as list
  -a Show hidden items (-A without . and ..)
  -r Invert order
  -R Recurse
  -S Sort by size
  -t Sort by date modified
mkdir -p Create dir with parents
cp -r Copy dir
rmdir -p Remove dir and empty parents
rm -rf Remove dir recursively, -f without confirmation
mv   Move recursively
find -iname pattern Search dir/file case-insensitive
  -mmin n Last modified n minutes ago
  -mtime n Last modified n days ago
  -regex pattern Path matches pattern
  -size n[kMG] By file size (-n less than; +n greater than)
  ! searchparams Invert search

File Manipulation

Command Param Description
cat file Print content
tac file Print content inverted
sort file Print sorted
  file -r -u Print sorted descending without dublicates
wc file Count Lines, Words, Chars (Bytes)
head `-n10 file tail -n5`
tail -f file Print new lines automatically
cut -f -4,7-10,12,15- file Print selected fields (tab delimited)
  -c -4,7-10,12,15- file Print selected characters positions
  -f 2,4 -d, --output-delimiter=$'\t' file Change delimiter (but use tab for output)
uniq file Hide consecutive identical lines
  file -c Show consecutive identical line count
  file -u Hide consecutive identical lines
file file Get file type

Archiving

Command Param Beschreibung
tar cfv archiv.tar file1 file2 Archiv erstellen / Inhalt hinzufügen oder überschreiben
  tfv archiv.tar Inhalt anzeigen
  xf archiv.tar [-C ~/extracted] Archiv (nach ~/extracted) entpacken (und dekomprimieren)
  cfvj archiv.tar.bz2 file bzip2 komprimiertes Archiv erstellen
  cfvz archiv.tar.gz file gzip komprimiertes Archiv erstellen
  cfa archiv.tar.[komp] file komprimiertes Archiv erstellen (auto Typ anhand Name)
bzip2 / gzip file1 file2 Dateien (einzeln) komprimieren
  -d file1 file2 Dateien dekomprimieren

Other

Command Param Beschreibung
<command> --help Help of current command (not standardized)
  -h  
  -?  
man <command> Manual page of command
  -k keyword Search command by keyword (oder apropos)
alias   Show aliases
  name='befehl' Create alias

Globs (Wildcards)

The dot . in front of hidden items is ignored by glob patterns!

Character Description
? Any single character
* Any characters
[ac-e] 1 character in enum
[!ac-e] 1 character not in enum
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

 Share

×
×
  • Create New...