All of these commands give you command-line option help by typing: $ [command] --help Don't use the brackets, they are there to denote the command. Some of these commands are in optional packages. Follow the prompt. Many of these commands will return a permissions error unless you precede it with 'sudo'. (Without the quotes, dear.)
Get more detailed help by typing: $ man [command]
Use the semicolon to run one after another until something goes wrong. $ [command 1] ; [command 2] Use double-ampersands (logical AND) to run next only when previous exits normally. $ [command 1] && [command 2] Use double pipe (logical OR) to run next only when previous exits with error. $ [command 1] || [command 2] Use both to do [if command 1 good, [command 2], else [command 3]] $ [command 1] && [command 2] || [command 3]
$ journalctl -k - Replaced "dmesg". System log for this boot. $ journalctl -k -f - Follow system changes. See USB add/remove, for example. $ journalctl --user -S today - See my modules load, plus much more. $ ls - list files $ lsb_release -a - shows the distribution version $ lshw - lists hardware drivers and stuff $ lspci - lists recognized pci bus stuff $ uname -a - displays the linux kernel version and hostname
$ arp - list active computers on network.
$ ip addr - show current Ethernet interfaces and IP address.
$ netstat - shows contents of /proc/net files.
$ tcpdump - inspect packets
$ ping - finds if remote computer is up
$ hostname - displays or changes my computer's hostname
$ traceroute - traces route from my computer to remote
$ tracepath - similar to traceroute
$ findsmb - find Windows shares
$ ifconfig - lists all interfaces running
$ ip - has pretty much replaced ifconfig. $ ip addr shows interface addressing
$ ifup - bring an interface up - ifup wlan0 (this is NOT: if up. It's "eye-eff" up. if for "interface".
$ ifdown - take an interface down
$ route - displays or modifies routing table
$ rfkill - overrides wireless status
ex: $ rfkill unblock wlan
$ sudo rfkill block wifi - to turn off wifi
$ sudo rfkill block bluetooth - to turn off bluetooth
$ iwconfig - displays wireless network interface information
Provides signal strength info
ex: iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY
$ iwlist - show info about WiFi interface.
ex: $ iwlist wlan0 scanning == show me everything around me
$ iwlist wlan0 freq == show me what bands work on this device
$ dhclient - get an IP address via dhcp
ex: sudo dhclient wlan0
$ host - provides basic info about an Internet host
$ dig - part of dnsutils package. "$ dig drgerg.com ns2.digitalocean.com NS"
$ whois - find the domain owner's information
$ wget - download file from website
$ curl - like wget with more - "curl -T
$ tmux - split one terminal into multiple terminals in one screen. CTRL-B % splits. CTRL-B ? for help. $ nmap - very powerful net scanner. ex: $ sudo nmap -sn 192.168.1.0/24 to list all devices on network. ex: $ sudo nmap -A 192.168.1.4 to show a lot of info on one device. $ links - text mode browser with mouse support $ pdftk - burst, combine, password protect pdf docs $ rl - randomize-lines, input text file, randomize the lines, output to file $ bless - GUI hex editor $ nvtop - NVIDIA card monitor. Must be running nvidia drivers. $ smartctl - See "DISK SPECIFIC". $ imagemagik - work with image files $ convert example.png -resize 1024 example.png (note only 1 dash in option) - - resizes using only width, keeping ratio, to same filename. - - (my personal scaling suffixes for Github: -s is 640. -vs is 320.)
$ ssh - logs you in to the remote computer terminal. Default port is 22. Other ports more secure. ex: $ ssh -p[port] user@remoteHost $ scp - Secure Copy. Copies files to or from remote over ssh. ex: $ scp -P[port] user@remoteHost:/path/to/file.ext /path/to/local/folder/ NOTE: reverse the order of the last two parts to copy a local file to a remote folder. $ ssh-keygen - generates a public/private key pair for you to use in automated authentication $ ssh-copy-id - authorizes you on a remote computer so you don't have to provide a password every time. NOTE: you have to already have access to the remote for this to work. You'll be prompted for your login password during the process. $ ssh-copy-id -i ~/.ssh/[key] -p [port] user@host.address As a general rule: on your local device, ensure permissions are: 0600 on the private key (owner read/write only, group & other NO) 0644 on the public key (owner read/write, group & other read only)
$ df - free disk space "df -h" produces short numbers $ du - disk usage - "du -s /500gig" for summary $ lsof - list open files: -i shows files open through network $ sudo update-grub - re-reads drives and configures boot loader $ dd - VERY powerful disk utility. Create disk images and more. ex: $ dd if=/dev/sda2 of=mysda2part creates a disk image named mysda2part. Check network speed using a combination of dd and ssh: $ dd if=/dev/zero bs=1M count=1000 | ssh -p[port] user@remote-computer 'dd of=/dev/null' $ blkid - get the UUID for a disk. Use 'sudo blkid /dev/part' $ smartctl - part of smartmontools. See SMART data for a drive. 'sudo smartctl --all /dev/sda'
$ adduser - add a new user. Also adds users to groups. $ addgroup - add a new group. $ mkpasswd - use to encrpyt passwords (read before using) $ passwd - change user password. SU can change forgotten passwords. $ usermod - make changes to user accounts. $ groups - shows what groups a user belongs to.
$ find - Find a file. "sudo find / -name Adafruit*" $ cat - Hugely useful program. Takes stuff in and puts it out. $ nc - netcat - does the same across a network connection. $ cp - copy files. 'cp -ar source dest' = recursive, keeps stamps. $ rsync - heavy-duty network file sync. $ dd - create disk images and more. $ chmod - change permissions flags on files and directories $ chown - change the owner and group of a file or folder $ chgrp - change only the group of a file or folder
Open text editor ex: $ sudo nano my_script opens the nano text editor under root permissions First line must be: #! /bin/bash Then put your command line commands one at a time like a DOS batch file. Save. $ sudo chmod 774 my_script changes the permissions flags to allow execution by owner:group in this case owner:group is root:root
Ghostscript (gs) is a powerful tool for converting graphics files. Example: Convert .ps file of a certain size to a .pdf file. $ gs -q -sDEVICE=pdfwrite -g5584x5024 -r300 -sOutputFile=UNT_racks.pdf UNT_300_port.ps
To see them: $ printenv HOME Shows Environment Variable "HOME" value. $ echo $HOME Shows shell OR environment variables. Shell vars are not persistent. To set them: $ export PATH="/newfolder:$PATH" Adds '/newfolder' to your existing path for this session. To Make Them Persistent, add to:
Last edited 04/08/2024 Four7zero.com is here courtesy of drgerg.com