Linux/1-Commands

From Wiki
< Linux
Revision as of 09:20, 2 February 2018 by Marcluer (talk | contribs)
Command Arguments Info Example Other

Basic
dir -Flah list folder content dir -Flah
cat %file show file content cat config.txt

Files
mkdir %dir create dir mkdir /var/test
rm %file remove file/dir rm autoexec.bat
cp %from %to copy
mv %from %to move
nano (%file) file editor nano
vi(m) %file file editor vi config.txt

Search
locate %file locate file locate fstab
updatedb update locate database
find / -n %filename search for file

System info
uname -a show kernel version uname -a
free -m show free memory free -m
fdisk -l
df -Th show harddisk usage df -Th
du
ifconfig show network settings
ps -aux show processes ps -aux
top show processes with UI
htop (extra package)
iotop (extra package)
iftop (extra package)
virt-top (extra package)
netstat
vnstat show network interface statistics (extra package)
who, w
pwd

Runlevel
runlevel
init %rlvl
halt
reboot
shutdown -h now

Network
wget download files
ntpdate (extra package)
dig get dns info
whois (extra package)
nslookup get dns info
finger (extra package)
route -n show active routes
traceroute show network route to target address
netstat -tulpn show open ports netstat -tulpn
iwconfig show wifi settings
iwlist scan scan for wifi networks
nethogs (extra package)

Apt
apt install <package> (-s = simulation) install package
apt update update list of available packages
apt upgrade upgrade packages
apt dist-upgrade upgrade all packages incl. kernel
aptitude package manager with UI
dpkg -c
dpkg --get-selections get list of all installed packages
/etc/apt/sources.list

HDD & Filesystem
dd if=%in of=%out low level copy dd if=/dev/sda2 of=/dev/sdb2
lsof show open files lsof | grep qcow
smartctl read smart info
hdparm set parameters
blkid show block devices
dosfsck -w -r -l -a -v -t /dev/sdc1 scan fat partition
fsck.ext4 -v -f -c /dev/sda1 scan ext4 partition

Helpers
watch -n 5 --differences repeat command every n seconds