Basic Linux
Basic Linux
Most commands have many parameters. Use “commandname - -help” to see these. E.g “chmod --help”.
Note that Linux expands wildcards (‘*’) as argument for shell programs in a much better way than
Windows.
Command Comment
apt-get cmd packet Debian Packet manager – for installs. “cmd” can be e.g. “install”
cat file1 file2 Concatenate one or more files together to output stream. Used often with single file and a “pipe”.
cd path Change Directory to Path. With no path you end in your home dir (/home/kelk in my case)
chmod file Change mode of file – e.g. to make it executable. See “ls –l”
chown file Change the ownership of a file
cp path1 path2 Copy path 1 to path 2. May copy folders recursively.
date Show date and time
df Disk free. Show the disk usage. Use ‘-h’ for human readable format.
find path -name file Search for file based on name – start from path. E.g. “sudo find / -name rc.c”
grep string Look in the stream for string. E.g. “cat myfile|grep -i beagle”. Use “” if there are spaces in the string.
ifconfig Interface Config. Shows connections. “-a” also shows whats configured – but not up.
ifup interface Interface Up. Interface is eg eth0, eth1, wlan0, usb0. There is also an “ifdown”
kill -9 n Stop process number ‘n’ (use after ps –a or ps –e).
ls path List - “Dir” on linux. “–a” shows all – including those with “.” first. “-l” is long version
lsmod Show (driver-)modules
lsusb Show USB devices. As in many other cases “-v” is verbose (detailed).
mkdir path Make Directory
man cmd Manual. Extensive description of any command.
more file Show the file a page at a time. Same as cat file|more.
mv path1 path2 Moves path1 to path2 name
nano path Basic text editor. Installed from start, works over a text ssh.
netstat Show network processes (as on windows)
nmap Network Scanner
ps Show processes. Typical options are ‘-e’ or ‘-a’
pwd Print Working Directory
rm path Removes a path. Take care when using “-r” (recursive)!
rmdir path Delete Directory
shutdown Typically “sudo shutdown –h now” – for halt now.
source file Run a script or binary file in current directory. Similar to ./file
ssh user@address Secure Shell. Modern “telnet”. Address can be an IP-address.’-X’ for graphics. VNC is an alternative.
sudo cmd Run cmd as superuser. You will be asked for password. sudo!! → latest sudo repeated
tail –n file Show the last n lines of a file. ‘-f’ will do this continuously, if the file is updated from another
process
tmux Terminal Multiplexer – have several open terminals in one window
top List the top CPU-demanding processes – ongoing updates. Use CTRL-C to stop.
tree Show semi-graphical view of directory structure (need to “apt-get install tree” first)
which cmd Tells where on the path the given cmd is found
whoami What is my current login name
Shell Tricks Comment
cmd-a | cmd-b “Pipe” output from cmd-a into cmd-b as input. E.g. “netstat –an|grep 5900” shows use of port
5900.
cmd & Run in parallel in the background. Use “;” to run commands sequentially
cmd-a > dest Output from cmd-a is input to dest (file or new cmd). “>>” appends. “>2” is errorout
CTRL-C Stop foreground execution
CTRL-Z Pause foreground execution. Type “bg” to continue in background
./file Run a script/program in the current dir. Avoids mistakes due to spelling errors!
TAB Commandline Completion. Use twice to see list of choices left.
Kelk 1I3
Linux CheatSheet
/ | |-- initramfs-tools
|-- bin Binary low-level stuff - system & user | |-- insserv
|-- boot Home of zImage (kernel) and config files | |-- insserv.conf.d
| `-- uboot uEnv.txt with kernel commandline. BBB HW | |-- iproute2
Docs | |-- javascript-common
|-- dev Special Device files | |-- kbd
| |-- block Block based. Links to RAM etc | |-- kernel
| |-- bus Bus devices - USB is here | |-- ld.so.conf.d
| |-- char Character-based. Links to TTY | |-- ldap Lightweight Directory Access
| |-- disk Links to disks by id, path etc | |-- libnl-3
| |-- dri | |-- lightdm
| |-- fd -> /proc/self/fd | |-- logcheck
| |-- input | |-- logrotate.d
| |-- mapper | |-- menu-methods
| |-- mqueue Message Queue (empty) | |-- modprobe.d Drivers – e.g Alsa sound conf
| |-- net | |-- modules-load.d
| |-- pts | |-- network
| |-- shm | |-- openal
| `-- snd Sound | |-- opt
|-- etc System related configuration! | |-- pam.d
| |-- ConsoleKit | |-- pcmcia
| |-- UPower | |-- perl
| |-- Wireless Default WiFi Configuration | |-- php5 PHP – mainly used in Webserver
| |-- X11 Graphical User Interface | |-- pkcs11
| |-- acpi Power-savings etc. | |-- pm
| |-- alternatives | |-- polkit-1
| |-- apache2 Apache Web-server | |-- ppp
| |-- apm | |-- profile.d
| |-- apparmor.d | |-- pulse
| |-- apt Packet Manager | |-- python
| |-- avahi Bonjour | |-- python2.6
| |-- bash_completion.d | |-- python2.7
| |-- binfmt.d | |-- rc0.d Runlevel 0 (halt) – links to /etc/init.d
| |-- ca-certificates | |-- rc1.d Runlevel 1 (single-user) – links …
| |-- calendar | |-- rc2.d Runlevel 2 (multi-user)
| |-- chatscripts | |-- rc3.d Runlevel 3 (multi-user with network)
| |-- chromium | |-- rc4.d Runlevel 4 (user-defined)
| |-- console-setup | |-- rc5.d Runlevel 5 (Normal)
| |-- cron.d Scheduler Daemon | |-- rc6.d Runlevel 6 (Restart)
| |-- cron.daily | |-- rcS.d
| |-- cron.hourly | |-- resolvconf
| |-- cron.monthly | |-- rsyslog.d
| |-- cron.weekly | |-- sane.d
| |-- dbus-1 | |-- security
| |-- default | |-- selinux
| |-- dhcp DHCP client config | |-- sgml
| |-- dictionaries-common | |-- skel
| |-- dpkg Base of Debian Packet Manager | |-- ssh Secure Shell - Keys
| |-- emacs Emacs Editor | |-- ssl Secure Sockets Layer – Certificates etc.
| |-- fonts | |-- sudoers.d Not really used
| |-- fstab.d | |-- sysctl.d
| |-- gconf | |-- systemd 1’st Process. System and User Conf.
| |-- gdb Gnu Debugger | |-- terminfo
| |-- groff Text Formatter. Low-level Word. | |-- timidity
| |-- gtk-2.0 | |-- tmpfiles.d
| |-- gtk-3.0 | |-- udev
| |-- hostapd Network config | |-- ufw
| |-- ifplugd | |-- usb_modeswitch.d
| |-- init Configuration Files for init | |-- vim
| |-- init.d Scripts/programs executed by the init daemon
| |-- wicd | |-- dbus
| |-- wildmidi | |-- initramfs
| |-- wpa_supplicant | |-- lightdm
| |-- xdg | |-- lock
Kelk 2I3
Linux CheatSheet
Note that /boot/uboot is the folder that is shared with a windows PC connected via the USB. Take care here.
Sample: /usr/local/share/emacs
Interpret: |----Scope---|Category|Application
Kelk 3I3