shell

Commandes UNIX

Commandes systeme $ uname –a # display linux system information $ uname –r # display kernel release information $ uptime # show how long system running + load $ hostname # show system host name $ hostname -i # display the IP address of the host $ last reboot # show system reboot history $ date # show the current date and time $ cal # show this month calendar $ w # display who is online $ whoami # who you are logged in as $ finger user # display information about user $ lsb_release -d # display ubuntu version Terminal related $ reset # Reset the terminal if display fucks $ stty insane # if previous doesn't work Hardware related $ dmesg # detected hardware and boot messages $ cat /proc/cpuinfo # CPU model $ cat /proc/meminfo # hardware memory $ cat /proc/interrupts # lists the number of interrupts per CPU per I/O device $ lshw # displays information on hardware configuration of the system $ lsblk # displays block device related information in Linux $ free -m # used and free memory (-m for MB) $ lspci -tv # show PCI devices $ lspci -nnk | egrep -iA3 "VGA" # display graphic driver information $ lsusb -tv # show USB devices $ lshal # show a list of all devices with their properties $ dmidecode # show hardware info from the BIOS $ hdparm -i /dev/sda -show info about disk sda $ hdparm -tT /dev/sda # do a read speed test on disk sda $ badblocks -s /dev/sda # test for unreadable blocks on disk sda Statistics and Analyze $ top # display and update the top cpu processes $ mpstat 1 # display processors related statistics $ vmstat 2 # display virtual memory statistics $ iostat 2 # display I/O statistics (2sec Intervals) $ tail -n 500 /var/log/syslog # last 10 kernel/syslog messages $ tcpdump -i eth1 # capture all packets flows on interface eth1 $ tcpdump -i eth0 'port 80' # monitor all traffic on port 80 ( HTTP ) $ lsof # list all open files belonging to all active processes $ lsof -u testuser # list files opened by specific user $ free –m # show amount of RAM $ watch df –h # watch changeable data continuously Utilisateurs $ id # show the active user id with login and group $ last # show last logins on the system $ who # show who is logged on the system $ groupadd admin # add group "admin" (force add existing group) $ useradd -c "Joe Smith" -g admin -m joe # Create user "joe" and add to group "admin" $ userdel joe # delete user joe (force,file removal) $ adduser joe # add user "joe" $ usermod # modify user information File Commands $ gpg -c file # encrypt file $ gpg file. »

Programmation Shell

Ajouter l’autocompletion aux parametres d’un script $ complete -W "mot1 mot2 mot3" script # Ajoute une liste finie de mots # A ajouter au .bashrc Voir Manual Bash Substitution des variables Instruction Signification ${variable} la variable. ${variable:-mot} la variable si elle existe sinon par le mot. ${variable:=mot} la variable si elle existe sinon par mot qui devient la valeur associée à variable. »