Working with a terminal can be confusing for newcomers. There are not the simple UI affordances avaiable in an app. Still, when working with a computer it is useful to have access to the raw power it offers.
In Linux, tools are intended to be modular components, each of which does one thing extremely well. These components are then chained together to perform more complex commands. While they may seem like a bizarre and clunky way of using an operating system, they are extremely powerful. In exchange for a small learning curve, you can automate a machine in ways that are completely impossible with graphical operating systems.
Commands are short to avoid excessive typing.
pwd
Stands for “print working directory.”
To show the contents of the current working directory:
ls
To see the contents of a different directory:
ls
Short for “list”.
More details:
ls -haltr /path/to/directory/
These options mean: * -h: Human readable (use Knstead of
printing all sizes in bytes) * -a: Include hidden files *
-l: Long format * -t: Sort by most recent time
modified * -r: Reverse. Puts the most recently edited on
the bottom, by the cursor.
More options can be found by reading the documentation:
man ls
cd /wherever/you/want/to/go
Short for “change directory.”
Conventions: * Folders end in a “/”, files end in their extensions. * Hidden files and folders begin with a “.” * The current directory is referred to as “.” * The directory above the current one is referred to as “..” * Your last location is referred to as “-”.
As an example, running:
cd ./../..
cd -
Will take you two directories above your current directly, then move you back to where you started.
less /path/to/file
Exit with “q”.
Name is an joke from the early days of Unix. The first text file viewer was named “more”, and only let you look forward through a file. less added the ability to go backwards, and caled less because “less is more.”
nano /path/to/file
Name is a mnemonic for minimal text editor.
If you want more power, and are willing to learn a small number of shortcuts to go faster:
vi /path/to/file
Many systems will also include vim, which is an extended
version of vi.
Named vi because it was the successor to an editor
called ex. vim is “vi improved.”
If you want a fully featured pre-internet text IDE:
emacs /path/to/file
Short for “editor macros,” a reference to it’s heavy use of macros.
Originally released in 1976, and has been under active development for almost 50 years.
Can rewrite itself on the fly.
Contains a full spreadsheet editor, mail client, computer algebra system capable of symbolic calculus, highlighting syntax support for dozens of languages, and more.
Very steep learning curve.
tail /path/to/file
Running:
tail -n 100 /path/to/file
Will print the last 100 lines.
Also comes with head, to see the first lines of a
file.
cat /path/to/file
Short for “concatenate,” because full purpose of this utility is to join files together by printing them out line-by-line. These streams can be joined together and made into new files.
cat fileA.txt fileB.txt > joined.txt
will concatenate fileA.txt and fileB.txt into a single file called joined.txt. The “>” takes the output of one command and writes it somewhere else, in this case a file. It might not sound like it if you are new to using the command line, but this is useful.
clear
grep "your search term" /path/to/file
grep supports an enormous number of options. A
few helpful ones: * -A x and -B x: Show x
lines above or below the found match * -i: ignore case *
-v: Exclude lines with this match instead of including
As an example, to check for Jingle errors in the Prosody logs:
cat /var/log/prosody/prosody.log | grep -i "jingle"
The name comes from the command “g/re/p” in the (extremely old)
ed editor, itself short for “general/regular
expression/print.” ed is still available but is no longer
in active use. Its interface was designed for pre-monitor computers
printing text on a piece of paper.
cp /path/to/source/file /path/to/location/to/copy/to/new_filename
So for example, to backup your Prosody config to a file named BACKUP.prosody.cfg.lua:
cp /etc/prosody/prosody.cfg.lua /etc/prosody/BACKUP.prosody.cfg.lua
This command is different from moving a directory, which is
mv, and has the same syntax.
Running:
find /folder/to/search/under
will give you a complete listing of all files inside that folder.
Your search can be narrowed down further using grep.
Find also supports executing a command on all matching files it
finds, using the -exec flag
apt install name_of_package_to_install
Short for “advanced package tool.” apt is the best
software installation tool you will ever use. One command, software
installed. It’s incredible.
If some piece of software requires root privileges, you will need to use sudo to run it:
sudo apt install name_of_package_to_install
The name is short for “superuser do.”
man program_name
Short for “manual.”
ifconfig
This command will list the IP addresses for the network devices attached to your machine, and some assorted statistics.
Short for “internet family configuration.”
dig yourdomain.com
The name is short for “domain information groper.”
All firewall managment is done through ufw, short for
“uncomplicated firewall.”
To open port 5222 for tcp packets:
sudo ufw allow 5222/tcp
To set your host to allow all outgoing connections:
sudo ufw default allow outgoing
To set your host to deny all incoming connections:
sudo ufw default deny incoming
This package may need to be installed:
sudo apt install ufw
ps -aux
Short for “process status.”
ping domain_or_ip_address
ping -6 domain_or_ip_address will perform this check
over IPv6.
Named as a pair, replies are called pongs.
Change owner:
chown ownername:groupname /path/to/file
Change just one file’s group:
chgrp groupname /path/to/file
Change group for every file in a folder:
chgrp -R groupname /path/to/folder/
Short for “change owner” and “change group”.
To change file permissions use the chmod command.
Linux’s permissions model is well outside the scope of this glossary,
run man chmod if you need the documentation.
ssh username@machine_name_or_ip_address
Stands for “secure shell”.
Not yet documented.
openssl s_client -connect uwuis.me:5349
-6)turnserver -c /etc/turnserver.conf -vsudo ss -tlnp | grep 5349openssl s_client -connect 127.0.0.1:5349ufwprosodyctl check turn -v
--ping=stun.conversations.imdu -h for human readable
formatting (traditional Kuffixes)dig SRV _xmpp-client._tcp.uwuis.me