Difference between revisions of "UNIX commands"

From Teknologisk videncenter
Jump to: navigation, search
m (Working with files)
m (Processes)
Line 138: Line 138:
 
! '''Command'''  ||  '''Explanation'''  || '''Example'''
 
! '''Command'''  ||  '''Explanation'''  || '''Example'''
 
|-
 
|-
ps || Process Status || ''Bash$ '''''ps –alf'''
+
|ps || Process Status || ''Bash$ '''''ps –alf'''
 
|-
 
|-
kill || Dræb en process || ''Bash$''' ''kill –9 1123'''
+
|kill || Dræb en process || ''Bash$''' ''kill –9 1123'''
 
|-
 
|-
nice || Juster process-prioritet || ''Bash$'' '''nice –n 18 myjob'''
+
|nice || Juster process-prioritet || ''Bash$'' '''nice –n 18 myjob'''
 
|-
 
|-
top || Vis processer og aktivitet interaktivt || ''Bash$'' '''top –S'''
+
|top || Vis processer og aktivitet interaktivt || ''Bash$'' '''top –S'''
 
|-
 
|-
shutdown || Luk systemet ned. (Kun superbruger) || ''Bash$ '''''shutdown –h 10'''
+
|shutdown || Luk systemet ned. (Kun superbruger) || ''Bash$ '''''shutdown –h 10'''
 
|-
 
|-
init || Skift kørselsniveau || ''Bash$ '''''init 3'''
+
|init || Skift kørselsniveau || ''Bash$ '''''init 3'''
 
|-
 
|-
exit || Afslut shell (bash) || ''Bash$ '''''exi''t'''''
+
|exit || Afslut shell (bash) || ''Bash$ '''''exi''t'''''
 
|-
 
|-
last || Vis login-historie || ''Bash$ '''''last –x'''
+
|last || Vis login-historie || ''Bash$ '''''last –x'''
 
|-
 
|-
uptime || Vis hvor lang tid siden maskinen bootede || ''Bash$ '''''uptime'''
+
|uptime || Vis hvor lang tid siden maskinen bootede || ''Bash$ '''''uptime'''
 
|-
 
|-
pstree || Vis ”familietræ” over processer || ''Bash$ '''''pstree –p'''
+
|pstree || Vis ”familietræ” over processer || ''Bash$ '''''pstree –p'''
 
|-
 
|-
procinfo ||  ||
+
|procinfo ||  ||
 +
|-
 +
|}
 +
 
 +
== Network Client programs ==
 +
{| border=1
 +
|- bgcolor=grey
 +
|+ network commands
 +
! '''Command'''  ||  '''Explanation'''  || '''Example'''
 +
|-
 +
|ssh || Secure Shell – Sikker terminalopkobling || ''Bash$'' '''ssh h4.tkgw.dhs.org'''
 +
|-
 +
|scp || Secure Copy – Sikker kopiering af filer mellem maskiner || ''Bash$'' '''scp filC root@h4:filD'''
 +
|-
 +
|telnet || Terminalopkobling – Ikke krypteret || ''Bash$'' '''telnet h4.tkgw.dhs.org'''
 +
|-
 +
|ftp || File Transfer Protokol – kopier filer via net || ''Bash$'' '''ftp h4.tkgw.dhs.org'''
 +
|-
 +
|talk || Chat med en anden bruger || ''Bash$'' '''talk heth'''
 +
|-
 +
|write || Skriv en besked til en anden bruger || ''Bash$'' '''write heth'''
 +
|-
 +
|mesg || Slå tilladelse til beskeder til/fra || ''Bash$'' '''mesg n'''
 +
|-
 +
|lynx || Tekstbaseret browser || ''Bash$'' '''lynx www.sslug.dk'''
 +
|-
 +
|wget || HTTP-klient. Kan hente helt site || ''Bash$'' '''wget www.sslug.dk'''
 +
|-
 +
|mail || Linieorienter mail-klient || ''Bash$'' '''mail heth@eucmidt.dk'''
 +
|-
 +
|pine || Skærmorienteret mail-klient || ''Bash$'' '''pine'''
 +
|-
 +
|}
 +
 
 +
== Terminals and Printers ==
 +
{| border=1
 +
|- bgcolor=grey
 +
|+ commands to handle Terminals and Printers
 +
! '''Command'''  ||  '''Explanation'''  || '''Example'''
 +
|-
 +
|tty || Vis filnavn terminal er tilkoblet || ''Bash$ '''''tty'''
 +
|-
 +
|stty || Vis/ret terminalegenskaber || ''Bash$ '''''stty –a'''
 +
|-
 +
|clear || Slet skærmbillede || ''Bash$ '''''clear'''
 +
|-
 +
|tput || Send terminalkoder til terminal || ''Bash$ '''''tput init'''
 +
|-
 +
|mingetty || Minimal getty – Starter loginsekvens op
 +
|-
 +
|agetty || avanceret getty – For eksempel til com-port
 +
|-
 +
|lpr || Print fil(er) || ''Bash$ '''''lpr –Plp1 filC'''
 +
|-
 +
|lp || Print fil(er) || ''Bash$ '''''lp –d lp1 filC'''
 +
|-
 +
|lpstat Printerstatus || ''Bash$ '''''lpstat –a –s'''
 +
|-
 +
|lpc || Print Control program || ''Bash$ '''''lpc'''
 +
|-
 +
|lprm || Fjern print-job fra printkø || ''Bash$ '''''lprm –Plp1 heth'''
 
|-
 
|-
 
|}
 
|}

Revision as of 15:31, 12 February 2009

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

User/Group rights and security

commands to work with security and rights
Command Explanation Example
su substitute – Skift brugeridentitet Bash$ su - heth
newgrp Skift gruppeidenditet Bash$ newgrp elev
who Vis aktive brugere Bash$ who
w Vis aktive brugere Bash$ w
finger Vis aktive brugere på denne eller en anden maskine. Er dog normalt slået fra via net, da hackere kan indhente informationer Bash$ finger root
chown Change Owner – Skift ejer på fil/bibliotek Bash$ chown jens filA
chgrp Change Group – Skift gruppe på fil/bibliotek Bash$ chgrp elev filA
chmod Change Mode – Skift rettigheder på fil/bib. Bash$ chmod 640 filA
chattr Change Attributes – skift udvidede rettigheder på et linux ext2/ext3 filsystem Bash$ chattr +A filA
lsattr Vis udvidede attributes Bash$ lsattr filA
passwd Skift passwd Bash$ passwd
umask Sæt/vis standard fil-mode ved oprettelese af fil Bash$ umask 022
id Vis login-rettigheder Bash$ id

Processes

commands to work with processes
Command Explanation Example
ps Process Status Bash$ ps –alf
kill Dræb en process Bash$ kill –9 1123
nice Juster process-prioritet Bash$ nice –n 18 myjob
top Vis processer og aktivitet interaktivt Bash$ top –S
shutdown Luk systemet ned. (Kun superbruger) Bash$ shutdown –h 10
init Skift kørselsniveau Bash$ init 3
exit Afslut shell (bash) Bash$ exit
last Vis login-historie Bash$ last –x
uptime Vis hvor lang tid siden maskinen bootede Bash$ uptime
pstree Vis ”familietræ” over processer Bash$ pstree –p
procinfo

Network Client programs

network commands
Command Explanation Example
ssh Secure Shell – Sikker terminalopkobling Bash$ ssh h4.tkgw.dhs.org
scp Secure Copy – Sikker kopiering af filer mellem maskiner Bash$ scp filC root@h4:filD
telnet Terminalopkobling – Ikke krypteret Bash$ telnet h4.tkgw.dhs.org
ftp File Transfer Protokol – kopier filer via net Bash$ ftp h4.tkgw.dhs.org
talk Chat med en anden bruger Bash$ talk heth
write Skriv en besked til en anden bruger Bash$ write heth
mesg Slå tilladelse til beskeder til/fra Bash$ mesg n
lynx Tekstbaseret browser Bash$ lynx www.sslug.dk
wget HTTP-klient. Kan hente helt site Bash$ wget www.sslug.dk
mail Linieorienter mail-klient Bash$ mail heth@eucmidt.dk
pine Skærmorienteret mail-klient Bash$ pine

Terminals and Printers

commands to handle Terminals and Printers
Command Explanation Example
tty Vis filnavn terminal er tilkoblet Bash$ tty
stty Vis/ret terminalegenskaber Bash$ stty –a
clear Slet skærmbillede Bash$ clear
tput Send terminalkoder til terminal Bash$ tput init
mingetty Minimal getty – Starter loginsekvens op
agetty avanceret getty – For eksempel til com-port
lpr Print fil(er) Bash$ lpr –Plp1 filC
lp Print fil(er) Bash$ lp –d lp1 filC
lpstat Printerstatus Bash$ lpstat –a –s
lpc Print Control program Bash$ lpc
lprm Fjern print-job fra printkø Bash$ lprm –Plp1 heth