Linux terminal commands

Lately quite a lot of friends and colleagues at work were talking about their recent switch to Linux. Rather strange since all of them were avid Windows users since the beginning of time, and some of them don't really hold the reputation of being, well, tech savvy. I was intrigued in a sense and inquired about their sudden motivation. These are the things that popped up: 1/ they heard a lot of stories about windows 10 and its data collecting (I don't know if any of these stories are true, but I read that the latest windows version collects quite a lot of its user's data which it sends back to US servers) 2/ they are sick and tired of the vast flow of updates, and 3/ especially the Linux flavour 'Ubuntu' is the first (?) Linux distro which is extremely 'ex-Windows-user' friendly. Gone are the days that a Linux user must-should be extremely technically minded. One can switch over to Ubuntu without too much hassle or complexity I was told. They said it is fun to work with the so called 'terminal' (typing in your commands with the keyboard, in Windows the DOS console) but it isn't a 'must' anymore. I spoke with several Ubuntu users sticking to the GUI of their Linux OS, doing everyday tasks (internet, email, video editing, playing audio files, watching movies, writing documents and fooling around with excel files) without going to the terminal once. So it works. It works right out of the box ;-) They said: install it, play with it and work with it. Obviously I was interested, and decided to give it a go myself. I used an old laptop that was lying around collecting dust and installed Ubuntu 16.04 LTS on it. That went quite well and fast. And it was a bit exciting as well ;-) Okay, in the beginning it did feel a bit strange and new. I had to find my way around and get used to the way new programs are installed, but I really got hooked rather rapidly! And everything is absolutely free! The OS with his absolutely free updates, the free programs, and one doesn't even need a virus killer anymore. I made a list of all the programs I regularly use on my Windows machine (also the ones I use rarely) and found exactly the same programs or equivalents for Linux. So I could compare, and some are indeed almost exactly the same, some are (really) better. And each and every program is freeware. With free updates and great active communities to give support or help me out (via websites and forums). I played around with the old laptop and my ubuntu Linux for about two months, and then created a dual boot on my (recent) more powerful desktop PC. A small partition is for my Windows and the rest is for Ubuntu 16.04 Actually, my friends told me it makes sense to keep windows on the side, especially if you're into playing computer games. But I disconnected my network card in Windows so it won't connect to the internet at all. Conclusion: I'm extremely satisfied with my switch, and I even started fooling around with the terminal, just for fun. I like it a lot but am aware that a lot of people won't be quite so enthusiastic. Luckily an Ubuntu user doesn't have to use the terminal at all. Especially for those who are about to anyway (or who want to try something new), I collected a bunch of commands which I will be sharing with you further on. Some are simple, some need root or super user privileges and others may be risky even. So use with caution. Use the '--help' or 'man' command to get more info or lookup more information on the net before using them. I don't see the point in putting up some pages about 'how to switch' to Linux since there are soooo many pages already available on the net. Just do a search on 'switch from windows to Linux' or 'installing Ubuntu 16.04', 'from windows to Ubuntu 16.4' or 'dual boot Windows and Ubuntu'. You will find hundreds if not thousands of pages with very useful step-by-step information!

(some) Linux terminal commands


The following terminal commands are fun, some may be complicated, others carefree and some of them may even be dangerous. Use the --help command to learn more or search after the command's do's and dont's on the internet before trying them out or using them on your machine.

'--help' : shows usage summary for that command (Usage: 'cal --help')

'man' : displays properly documented pages (Usage: 'man cal')

'alias' : is another name for a command

'grep' : searches for a pattern in a file

'badblocks -s /dev/sda' : perform test for unreadable blocks on disk sda

'cal' : display calender with current month

'cat' : view the contents of a file.

'cd' : change the current working directory to the directory provided as argument

'clear' : clears the screen

'cp' : copy file and-or directory command

'date' : display current time and date.

'date +%T' : display current time

'date -d fri' : what date is it this friday

'df' : reports file system usage

'df -h' : Show free space on mounted filesystems

'df -i' : Show free inodes on mounted filesystems

'du' : determines disk usage of a file

'du -hs /home/* | sort -k1,1h' : Sort paths by easy to interpret disk usage

'du -s * | sort -k1,1rn | head' : Show top disk users in current dir.

'echo' : echo whatever you provide it

'ethtool eth0' : Show status of ethernet interface eth0

'fdisk' : tool for getting partition information and adding and removing partitions

'file' : determines the file type of a file

'find -maxdepth 1 -type d | while read dir do echo $dir echo cmd2 done' : Process each item with multiple commands (in while loop)

'find -maxdepth 1 -type f | xargs grep -F 'EXMPLE' : Search all regular files for EXMPLE in this dir

'find -name '*.[ch]' | xargs grep -E EXPR' : Search EXPR in this dir and below.

'find -type d ! -perm -111' : Find dirs not accessible by all

'find -type f ! -perm -444' : Find files not readable by all

'find -type f -print0 | xargs -r0 grep -F EXMPLE' : Search all regular files for EXMPLE in this dir and below

'free -m' : display amount of (remaining) RAM (-m displays in MB)

'grep MemTotal /proc/meminfo' : display RAM total seen by the system

'hdparm -i /dev/sda' : display info about disk sda

'hdparm -tT /dev/sda' : perform a read speed test on disk sda

'head' : display the first few lines of the file

'history' : shows the commands you have entered on your terminal so far

'host' : Lookup DNS ip address for name or vice versa

'hostname -i' : Lookup local ip address (equivalent to host `hostname`)

'id' : prints user and groups (UID and GID) of current user

'info' : often more elaborated than man pages (Ex: info date)

'ip addr show' : List addresses for interfaces

'ip link set dev eth0 up' : Bring interface eth0 up (or down)

'ip link show' : List network interfaces

'ip route show' : List routing table

'join -t'\0' -a1 -a2 file1 file2' : Union of sorted files

'join -t'\0' file1 file2' : Intersection of sorted files

'join -t'\0' -v1 -v2 file1 file2' : Symmetric Difference of sorted files

'join -t'\0' -v2 file1 file2' : Difference of sorted files

'last' : display information about the users who logged in and out of the system

'lastb' : shows last bad login attempts

'ln' : creates links

'locate -r 'file[^/]*\.txt' : Search cached index for names

'ls' : displays contents of current directory

'ls -l' : displays contents with more detail

'ls -l -a' : displays hidden files as well

'ls -lrt' : display files by date

'lsusb -tv' : display USB info

'mkdir' : create a directory

'mtr' : ping and traceroute combined

'mv' : move file and-or directory command

'netstat' : check the network statistics of the system

'passwd' : to change your password

'ps -C firefox-bin -L -o pid,tid,pcpu,state' : List all threads for a particular process

'ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d' : List processes by % cpu usage

'ps -e -o pid,args --forest' : List processes in a hierarchy

'ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS' : List processes by mem (KB) usage.

'pwd' : command prints the absolute path to current working directory.

'pwd' : displays current directory

'recode -l | less' : Show available conversions

'rmdir' : removes any empty directories

'shutdown -h' : shut down your system

'ss -tup' : List active connections to/from system

'ss -tupl' : List internet services on a system

'stat' : check status of a file

'tail' : shows last 10 lines by default

'tcpdump not port 22' : Show network traffic except ssh

'time cat' : Start stopwatch. Ctrl-d to stop

'touch' : create an empty file

'w' : check which users are logged in to the system

'wc' : counts lines, words and letters of the input given to it

'whatis' : gives a one line description about the command (Ex: whatis cal)

'whoami' : reveals the current logged in user

'whois' : lookup whois info for hostname or ip address