Linux Commands

Quick Reference


view program manual:        man {program}
view program help:            {program} --help (or -h may work)


List recently used commands:        history
Clear terminal window:                   clear
run as super user:                            sudo
load desktop from terminal:            startx
run gui program as super user:       gksu
shutdown (halt or restart):               sudo shutdown now [-h] [-r]

Software versions

kernel/os/platform:                         uname -a
distribution:                                     lsb_release -a
package:                                           dpkg --list (package) e.g. dpkg --list python
program version:                            {program name} --version or -v

List files, harwdare, environment

files in current dir:           ls [-l]    inc hidden files [-a]
USB devices:                  lsusb
PCI:                                 lspci
open files:                       lsof
block devices:                lsblk
hardware:                      lshw
modules:                         lsmod
environment vars:            env
cpu:                                cat /proc/cpuinfo

Memory, drives, volume, file system

disk usage:                       df [-h] [-hT]
RAM:                                free [-h]
RAM:                                cat /proc/meminfo
mount filesystems:            mount / umount

file, folder, drive operations

change directory:            cd
make/remove:                  mkdir/rmdir
view file contents:            cat {path+file}
compare file:                    diff
copy file:                           cp
remove file:                      rm {file}
find file:                             find
find text in files:               grep
find program files:            where is {program}
change mode (r/w/exe):    chmod
create program alias:        alias {program name only}
File/image copy:               dd or dcfldd
remove old .debs:             sudo apt-get clean
execute permission:         chmod +x {filename}


view current processes:        top
get process id (pid):               pgrep {process name}
send signal to process:          kill {pid}

Network and web

check interface details:         ifconfig
bring up/take down:              ifup/ifdown
display/change wireless:       iw list
config wireless:                    iwconfig
detailed:                                iwlist
port scanner:                        nmap {ip}
find network devices:            e.g. nmap
net statistics:                        netstat -a
active tcp/udp:                      netstat -atu    (or -atuc for continuous)
inspect tables:                       iptables --list
my traceroute:                     mtr {ip}
echo request:                       ping {ip}
generate WPA PSK:              wpa_passphrase {ssid} {passphrase}
get a web page/file:              wget
remote ssh access:                ssh {user}@{ip}    e.g. ssh pi@
exit remote ssh session:       exit

Samba; test config file:        testparm
Samba; display shares:        smbtree

Boot time analysis

boot stats/info:                      systemd-analyze
list, longest first:                    systemd-analyze blame
time critical chain:                 systemd-analyze critical-chain

Full reference:

Raspbian specific

Raspberry Pi config:             raspi-config
update Pi firmware:              rpi-update
Pi software ref (date):           cat /boot/issue.txt
update software:                   sudo apt update && apt upgrade
copy Pi image from SD:       dd if=/dev/{sd id} of=/home/{user}/{img name} bs=1M
    e.g.   sudo dd if=/dev/mmcblk0 of=/home/steve/Pi_Images/blissflixx.img bs=1M

cpu, serNo, revision:            cat /proc/meminfo
RAM for cpu:                        vcgencmd get_mem arm
RAM for gpu:                        vcgencmd get_mem gpu

redirection, pipe

No comments:

Post a Comment