UNIX commands

From Teknologisk videncenter
Revision as of 13:18, 12 February 2009 by Heth (talk | contribs) (Searching for Files and storage)
Jump to: navigation, search

Basic UNIX/Linux Commands

On line help

On-line help commands
Command Explanation Example
man Se en kommandos manualside. Bash$ man find
info Generel hjælp eller hjælp til enkelte kommandoer Bash$ info
apropos Vis kommandoer som minder om en kendt Bash$ apropos chmod
help Viser bash shellens indbyggede kommandoer Bash$ help

File handling

File handling commands
Command Explanation Example
cp CoPy - Kopier fil(er) Bash$ cp filA filB
mv MoVe – Flyt eller omdøb en fil Bash$ mv filB filC
ln LiNk – Opret en link til en fil eller bibliotek Bash$ ln filC filD
rm ReMove – Slet filer og biblioteker Bash$ rm filA filB
mkdir Opret bibliotek Bash$ mkdir heth
rmdir Slet bibliotek. Skal være tomt Bash$ rmdir heth

Searching for Files and storage

File search and storage commands
Command Explanation Example
ls LiSt - Vis liste over filer og biblioteker Bash$ ls -asl
pwd Print Working Directory - Vis nuværende arbejdsbibliotek Bash$ pwd
find Søg efter filer og kataloger Bash$ find / –name filA
du Disk Usage – Viser forbrug af diskplads Bash$ du /home/heth
df Disk Free - Viser totalt forbrug/plads på diske Bash$ df
cd Change Directory – skift arbejdsbibliotek Bash$ cd /home/heth

Working with files

commands to work with content of files
Command Explanation Example
cat concatenate – Vis fil Bash$ cat /etc/passwd
more Vis fil en side af gangen. kan bladre frem Bash$ more /etc/passwd
less Vis fil en side af gangen kan bladre frem og tilbage Bash$ less /etc/passwd
head Vis første liner af fil Bash$ head /etc/passwd
tail Vis sidste linier af fil – God til at se logfiler med dynamisk. Se option –f i manual bash$tail /etc/passwd
cmp Compare – sammenlign to filer Bash$ cmp filA filB
diff Difference – sammenlign to filer Bash$ diff filA filB
cut Udvælg søjler i fil Bash$ cut –d: -f5 /etc/passwd
wc Word Count – Tæl linier, ord eller tegn Bash$ wc –l /etc/passwd
tr Translate – Søg og erstat tegn tr a-z A-Z
grep Find linier med bestemt indhold Bash$ grep heth /etc/passwd
sed Seriel Editor – Ofte brugt i scripts til editering af tekst
file Vis hvad type af indhold filer har Bash$ file *
pr Print Formatter – Formaterer tekst til print Bash$ pr –h ”rapport” filA
vi Visual – Populær editor Bash$ vi filA
pico Populær editor Bash$ pico filA
emacs Populær editor Bash$ emacs filA
tee split stdout fra et program i flere tee filB