More Command Line Tools

dpkg-reconfigure tzdata – change the time zone. I had to do this on an Ubuntu Server virtual machine which I use for my weather info Twitter bot. In the later chapters about web development, you might want to set up a Linux server VM as well, so this is a useful command to know so that your server has the correct time for the time zone you’re in.

apropos – see what something is used for or when it’s mentioned in other program descriptions.

whereis – find the location of a program.

whatis – see a brief one-line description of a program.

htop – a more powerful version of top, but it often doesn’t come with OSes by default and has to be installed separately, such as with sudo apt-get install htop on Linux or brew install htop on macOS.

find – find something.

df -h – a human-readable way of viewing disk usage.

Pipes – you can take the output of one program and put it into the input of another program using pipes. Here is an example: history | wc

That takes the output from the history command and gives it to the wordcount command.

Imagine that programs are machines, which you can connect together using pipes. A pipe allows for data to flow out of one program and into another. That’s the analogy that was used for coming up with the name “pipe.”

wc – wordcount. You can use it with the -l option to view the number of lines something is. You can also use it with a pipe to see the number of lines the output of something is.

tee – a way of having output still show up on screen but also be directed somewhere else, such as being logged to a file.

grep – a way to search for things. Let’s say you have a disorganized folder. You have a thousand files in a single directory, and you’re not sure if a particular file is in it. You could manually scroll through the output of ls, or you could do something more efficient: pipe the output to grep and search for it.

Here’s an example:

ls -a | grep project

Then it will show you if any results have the string “project” in them. If there are no results, you will see nothing.

env – list all environment variables.

w – show a list of logged in users on the machine. As a general rule of thumb, there will be one more than you expect. For example, if you have one logged in user and one terminal open (typical for most people), you will see two users there. That’s normal. If you have two terminals open, you will see three. That’s because the other one is just there from you being logged into your computer. But if you see a user that you’re not expecting, that could be a sign of being hacked – or you just misinterpreting the results, or a program using a service account for something.

who – very similar to w, but with more compact output.

netstat – shows current internet connections. You might want to filter the results. netstat -a shows everything, but the output will be hard to parse by itself. If you have recently connected to a website, it might show up in netstat until the connection expires.

ipconfig /release – get rid of your current DHCP lease on Windows.

ipconfig /renew– get a new IP address from your router. This is internal, and if you’re using NAT (Network Address Translation, which translates public IPs to private ones and vice versa), this won’t change your public IP.

ipconfig /flushdns – gets rid of your current DNS cache, which can solve certain kinds of connection issues.

traceroute – view all the hops from your computer to a server. There are many intermediary routers in between you and the destination server you want to connect to, just like how there are many streets and intersections between you and a place you might want to drive to.

read – a way to get user input in a bash script and then store it to a variable, like this:

#!/bin/bash

echo -n “Enter your name: “

read choice

echo -n “Hello, “

echo $choice

python or python3 – ways of using the Python interpreter from a command line. I recommend using python3, but depending on your computer, you might have it set up so that python starts python 3.

python –version or python3 –version – check which versions of python you have installed on your computer.

quit() – enter this command to quit python. You need the open and closing parentheses for it to work because it’s a function that takes no arguments.

quit or exit – leave something, such as a shell, a terminal window, or an SSH session.

ctrl+c or ctrl+x – ways of stopping a currently-running program in a terminal. Sometimes, a command line program will not respond, so you need to do this to quit it.

/dev/null – a place you put stuff (such as output from a program) when you don’t want it. It’s called a bit bucket. Back in the day, when computers used punch cards, they would punch holes, which would leave little things referred to as bits. The bits were trash and would need to be placed somewhere, which was called the bit bucket — a place for undesirable things in a computer that you want to discard.

Try running these two commands and look at the difference:

echo hello

echo hello > /dev/null

The following is a way of getting rid of error messages:

./some_program 2> /dev/null

That being said, error messages usually happen for a reason, so you might not want to ignore them. But sometimes, they’re benign and can be ignored.

ssh – Secure Shell. A text-based method of remotely logging into something. Graphical alternatives include LogMeIn, TightVNC, Microsoft Remote Desktop Protocol, and Chrome Remote Desktop. However, SSH is generally more secure and is an industry standard. To log in with ssh, you first need to set ssh up and then log in using ssh [email protected] or ssh [email protected] or whatever the IP address is that you want to log into. Then it will prompt you to enter your password. You can also specify which port to use, such as ssh -p 5555 [email protected]. A common piece of software people use for Windows is called PuTTY, which is a client for SSH and telnet. Telnet is like SSH, only not secure. Don’t bother with telnet.

Terminal multiplexer – software that splits one terminal into many terminals, making it easy to use many different command line tools at the same time. For example, you can have your terminal window full-screen and have it split into 4 terminals in a 2×2 grid. Some examples include screen and tmux. A more user-friendly alternative to a “true” terminal multiplexer would be terminal programs like Terminator or ConEmu.

chmod – change file mode bits. You can change the permissions of a file this way. For example, if you wrote a program and you want to be able to run it, you have to set the executable bit. You can do this with chmod +x, where x means execute. Execute means the ability to run something as code instead of only viewing it as text. You can remove permissions with -, such as chmod -x to remove the ability to execute the file as code rather than just viewing it as text. You can also specify the octal permissions numerically, such as chmod 755 some_file.

chmod u+x means the user who owns the file gets +x (execute).

chmod o-w means the “other” category loses the ability to edit or delete (write) the file.

chmod ug+r means the user and users within the same group gain the read permission.

chmod -x means the user, group, and other all lose the execute privilege.

s instead of x for execution – some programs use setuid, meaning the process runs as a different user (the owner of the file) rather than the person who runs it. for example, a user might run something that is owned by root and it gets run with elevated privileges.

chgrp – change group ownership.

chown – a command for changing the owner and group of a file.

adduser – add a new user.

deluser – delete a user.

delgroup – remove a user from a group or delete a group.

/usr/share/dict/words and /usr/dict/words – dictionary file word lists in Unix-like OSes. Every word is on a separate line. A dictionary file is not the same thing as a dictionary data type.

Unix file mode bits – the three types of permissions in Unix are read, write, and execute.

Read: the ability to open a file to view its contents.

Write: the ability to create, edit, or delete files.

Execute: the ability to run a program as code rather than merely viewing it as data.

Principle of least privilege: only give permissions when they are absolutely necessary.

You also need to be aware of the three distinct groups – user, group, and other. User is the person who owns the file, group would be people in the same department in a company, and other is anyone else. Sometimes, a file’s permissions will be listed as something like rwxr-xr-x or 755. The first three letters are for the user, the next three are for group, and the last three are for other. Numeric representations represent the three bits. 7 is 4 + 2 + 1, meaning full permissions. 5 is 4 + 1. In octal permissions (base 8), 4 represents read, 2 represents write, and 1 represents execute. So 5 means read and execute but not write. 0 means nothing is allowed for that particular category (for either user, group, or other). chmod 777 is a lazy and really bad way of dealing with permissions because it lets everyone do anything with it. Things should be given permissions on an as-needed basis, not just for everything.

Want to view file permissions for everything in your current directory? Do this in a terminal:

ls -l

nano – a simple command line text editor that some people prefer over vi/vim because it’s easier to use. It tells you which key combinations to press in order to do which things.

pwd – print working directory. It tells you what folder you’re currently in.

scrot – a tool for taking screenshots.

bcrypt – a command-line encryption and decryption tool that uses the Blowfish encryption algorithm.

cowsay – a silly program that lets you make it look like a cow is saying something. You can also pipe the output of one program into cowsay to make the text art cow say it.

Examples of cowsay:

cowsay moo

uname -a | cowsay

passwd – a command line tool for changing a password.

fortune – a semi-useless but amusing command line program that tells you your fortune. Back in the day, when I learned command line stuff, a lot of it was dry and boring, but cowsay and fortune provide some silly entertainment to make it more interesting, at least when starting out.

su – log in as the super user (root). On Windows, you might be familiar with the term “admin” instead of root, but they are similar concepts. su is different from sudo because su logs you in as root for as long as you have your terminal session active (or use a command like exit to go back to being a normal user again), whereas sudo is temporary, like if you can get by with running most commands as a normal user account, and then only want to run a single command as root. For most cases, it’s best to use sudo instead of su.

$PATH variable – A significant environment variable that can be hard to understand at first. In the $PATH variable, which you can view by typing echo $PATH, there’s a list of directories for executables. The order of this list matters. When you type a command, such as echo, first your computer will look in the first directory specified in the PATH variable, and if nothing is there, it will go to the next one. These directories are delimited using colons. Sometimes, to get a program to run correctly, you will need to add it to your PATH variable. Issues with your PATH variable can be frustrating and can make it so you can’t run something, or at least not run it properly. I personally never learned about it until I encountered problems with it, at which point I looked it up and learned what it is in order to fix it. There are a lot of tech things that are like that – they work silently in the background, and you never notice them until something goes wrong.

One trick I’ve learned over the years is to include your own scripts folder in your PATH variable so that you don’t have to do tons of .bash_profile aliases to run your own programs, such as shell or python scripts. That way, you can run your programs even when you’re not in the directory that the program is in.

Aliases are still useful, but instead of using aliases for your program names, you should use them for things like common misspellings of commands (such as alias cs=”cd” instead of cd), or for running commands with arguments (like alias ls=”ls -ahl”) without having to type them in every time, or some one-liner that you find yourself using a lot, such as the following:

alias compcode=”g++ -std=gnu++14 main.cpp -o hello.out”

$ – in a shell script or shell command, a $ before something indicates that you are referring to a variable, not a string. echo $PATH will echo your path variable, whereas echo PATH will just literally show the text “PATH.”

sudosuper user do, do something with elevated privileges. Don’t run things with elevated privileges unless you absolutely have to.

alias – if you want to create your own shorthand command for something, or you find yourself misspelling something a lot, you can create an alias for it. ls is a useful command you will use often. Let’s say you accidentally type sl instead of ls a lot. You can create an alias using this command:

alias sl=”ls”

Then, when you hit sl, it will execute the ls command instead. But if you just create an alias, when you restart your computer, it might be gone. So you will need to add it as a line to a shell configuration file. If you’re using bash, the file will be .bashrc or .bash_profile in your home directory. If you don’t already have one, you will need to make one. If you’re using macOS and using zsh, you will need to use .zshrc instead of .bashrc.

tr – character translation. Substitute one character for another. Among other things, you can use it to change the capitalization of things in a shell script. This command is typically used with pipes. You pipe data into it, such as maybe the output of the cat command for a text file, and then tr will take that unformatted text and translate the characters based on the parameters you specify.

wget – a tool for downloading files or web pages.

curl – kind of like wget, you can use it to download things, or craft certain kinds of requests, which can be useful for web development testing.

bash – if you’re using a different shell, you can use the bash command to switch to a bash shell instead.

chsh – changing your shell once with the bash command is only temporary, just like the alias thing I mentioned earlier. But if you want a persistent change your shell, so that you will always start with a preferred shell, use the chsh, or change shell, command. You might have to use the source command or log out and back in again for it to take effect.

zsh – an alternative to bash, it’s a shell with a lot of powerful features. Newer versions of macOS will come with it as the default shell. However, it is possible to change your shell if you’d rather use something like bash instead.

oh-my-zsh – a plugin for zsh which adds additional capabilities.

fg – continue a job in the foreground.

bg – continue a job in the background. This isn’t specific to the bg command, but there is a lot of stuff running in the background, not just what you see on your screen. Some software doesn’t need any window at all to run. A lot of software runs automatically, such as daemons, which wait to be used.

jobs – view all jobs.

something& – run a program called “something” (replace with whatever program you want) in the background so you can continue to enter text commands while it’s running. If you don’t want to get into terminal multiplexing, you can always use background jobs.

tar – a tool for compressing and decompressing archives. You can put lots of files into a single compressed archive, using extensions like .tar, .tar.gz, .tar.bz2, .zip, and so on. tar is short for tape archive, though it has become useful even for things that aren’t related to tape drives. Fun fact: tape drives, despite being ancient, are still widely used for enterprise backups to this day because of how cheap they are compared to SSDs or hard drives. Tape drives can do sequential reads and writes of data just fine, but random writes/reads are glacially slow. They’re good for backups, but not for files you’d want to access on a daily basis.

Tarball – a compressed/group collection of files that have been put together and compressed using the tar or gzip utilities. It’s kind of like a .zip or .rar file. Two common tarball file extensions are .tar.gz or .tar.bz2, such as site_backup.tar.gz. tar means tape archive, and gz is short for gzip, which means the GNU zip utility. Another archiving utility is bzip2, which uses the .bz2 extension. There are two purposes for zipping files – firstly, they are compressed, which reduces the file size. Secondly, they are grouped together in a single file, which is convenient for dealing with many files that are all in the same project, such as files for a program.

zcat – a tool for viewing the contents of a compressed archive without actually unzipping it first. Please note that viewing contents this way is significantly slower than unzipping them first.

head – get the top of the output of something.

The following command will get the first 5 entries from the output of the history command:

history | head -n 5

; – run one thing followed by another (for a shell script or command line command).

clear; uname -a

In a language like Java or C++, you will have to use a semicolon at the end of a line. Python does away with semicolons in this way though.

tail – get the end, or tail, of something.

The following command will get the last 2 entries from the ls -a command:

ls -a | tail -n 2

less – if the output of a program is too long, you might want to use a kind of program called a pager. A pager will let you scroll through the output. less is a commonly-used pager program. You can hit q to quit it.

ls -a /dev/ | less

!! – Repeat the last command used. Alternatively, you can use the up arrow key to scroll through the previous commands you used. There is another related usage for exclamation points.

Let’s say you recently used the python3 command. If that was the last command you used that started with the letter p, you could use !p to rerun python3. If you’ve been recently running multiple commands that start with the letter p, you can make sure to disambiguate by using more letters, like this:

!py

sleep – pause for a certain number of seconds. I’ve used sleep in shell scripts where you want to read the output of something, but the computer does it faster than you can read it, so you put little pauses here and there. You can also use it to wait for something to complete, or to wait to decrease CPU usage instead of going as fast as possible, which is what will happen if you don’t add a sleep here and there.

Another cool trick for how to slow down program execution until the user is ready is with the read command. Recall that the read command waits for the user to type input and then hit enter. You don’t necessarily have to do anything with the input from the user, and instead can use it to make it so that the program stops until the user hits enter, at which point the program continues. You might want to put an echo before you read, like echo Hit enter to continue.

./example – execute a file called example which is located in the current directory. The executable bit must be set with chmod for you to be able to do this. Depending on who made it, you might not have permission to run something or to change its ability to be executed/run. You can run a python program with ./example.py or python3 example.py.

.. – Up one level. If you are in the /Users/alan/ directory and use the command cd .., you will go up to the /Users/ directory. You can combine going up with going down. If you are in the /Users/alan/ directory and want to go into /bin/, you can use the following command:

cd ../../bin

That makes it go up one level, then up one level again, and then down into /bin/, which is short for binaries. It’s where standard executables are located in Unix-like OSes.

cd – – if you want to go to the last directory you were in, no matter what it was, use cd –

. – the current directory. Let’s say you want to copy a file from a different directory into your current one. You could use a command like this:

cp ~/whatever/example.txt .

Then it will copy example.txt into the directory you are currently in.

ps – show running processes on your computer that you own.

ps ax – show all processes, even ones that aren’t yours (based on the current user you’re logged in as).

pid – a programming that is currently running has something called a process. pid is the Process ID. If you want to end a particular process, you can use kill

[some pid number]

. A pid is assigned based on when it was run, and how many previous processes there are. So a program might be a certain pid number one day, and a different one the next (if either the computer or the program has been restarted).

kill – end a process. By default, you will send a signal that will tell the program to wrap up and then close at the program’s earliest convenience, perhaps syncing with a server or saving files before shutting down. But if something truly isn’t responding or doesn’t want to stop, you can use kill -9 to force the process to end immediately. kill means SIGTERM, which is gentler, but kill -9 means SIGKILL, which is more hardcore. It’s best to use SIGTERM unless a program won’t end for some reason (such as an issue that is causing it to hang indefinitely). Only use SIGKILL as a last resort.

killall – kill all processes with a certain name, like killall firefox. Useful when you have a program open that uses multiple threads, or when you have multiple instances of the same program open.

pidof – if you want to kill a process with kill, you use a process ID number. But what if you know the name of the program but don’t know the pid? Use something like this:

kill `pidof program_name`

The above characters are back-ticks, not single quotes. Back ticks are on the same key as tilde (~).

pkill – a way to kill a process by name, such as pkill program_name.

du -sh – show the size of a directory. If no directory is specified, it will default to your current working directory. But you can also choose a different directory to analyze. The bigger the folder is, and the more files that are in it, the longer it will take to compute.

shuf – shuffle lines, such as from a file.

/dev/random – random number generator, but it relies on an entropy pool, which can be exhausted, meaning it can run out of random numbers to give you. There are concepts in programming called producers and consumers. /dev/random is an entropy pool consumer. Having a source of stochastic data can help with all sorts of things, such as generating hard-to-guess passwords, shuffling cards in a deck, distribute things, or making AI in a game not do the same thing every time. Another interesting use is to use random timing or mouse movements to make a bot appear to be more human because people don’t do the exact same thing every time.

cat /dev/random

The output will scroll quickly, and it will look like complete gibberish, but there are ways you can use it to get meaningful random numbers, such as with tr. Remember that you can hit ctrl+c or ctrl+x to get out of a program. ctrl+c is like “quit” and ctrl+x is like “force quit.”

/dev/urandom – unlike /dev/random, /dev/urandom won’t run out of an entropy pool. This is pseudorandom, not something you should rely on for mission-critical things or anything security-related. Be warned: /dev/random and /dev/urandom can cause your CPU to heat up a lot if you use it for an extended period of time. So be sure you know how to exit it before trying it out. This is less of a problem for desktops, especially ones with aftermarket heatsinks, but it can be an issue on small laptops that don’t have very good cooling solutions.

mount – mount a volume, such as a partition on a hard drive.

umount – unmount a volume.

> – write contents to a file.

echo hello > example.txt

echo hi > example.txt

This will overwrite whatever contents were previously in the file. With those two commands above, the contents of example.txt will only be “hi” and nothing else. First, “hello” is written to the file. Then “hi” writes over the existing contents, so the “hello” is lost. This can be bad in a lot of cases.

>> – append to a file, also known as concatenation. This will add to a file without deleting what is already in it.

echo hello >> example.txt

echo hi >> example.txt

The previous two commands will make it so that example.txt contains hello and hi in addition to whatever was in the file before you ran the commands.

stdin –standard input.

stdout –standard output. > or 1> is stdout.

stderr – standard error output, 2>

&> – both stdout and stderr.

cat – a tool for viewing the contents of a file. I find that it’s useful to use cat with grep, head, and/or tail, because some files are so big that it would be a mess to look through the entire output of cat, such as for long log files with hundreds or even thousands of entries.

echo hello > example.txt

cat example.txt

hello

tac – like cat, but it prints the lines in a file in reverse order, rather than from beginning to end.

Let’s say this is the output of a file called numbers.txt:

cat numbers.txt

1

2

3

4

tac is the opposite:

tac numbers.txt

4

3

2

1

jq – a command line tool for parsing, slicing, and searching through JSON files. Remember: if a command line utility doesn’t work from a shell, you will need to install it first, such as through a package manager.

/etc/sudoers – a list of users who are allowed to use the sudo command. If you get an error saying you’re not in the lits of sudoers when you try to do something that requires extra privileges, you will have to add your user account to the sudoers list. Only macOS and Linux have this. Even if you have Git Bash on Windows, it won’t have a sudoers file.

java – you can use the java command line command to run a java program, or check what version of java you have.

java –version

java -jar program.jar

yes – some programs will require you to hit y or yes to proceed. It might say something like this:

Are you sure you want to do [something]? (Y / N)

Yes or no confirmations are common in command line programs. Even trying to install something with your package manager might require you to confirm that you want to install it.

If you pipe the output of yes to the input of a program that requires a yes or no confirmation to proceed, it will be input a yes answer automatically, allowing the program to get past a yes or no confirmation without the user actually typing it. This can be useful if you want to run a shell command on a set schedule with no user input. For example, you might create a shell script that automatically installs software updates, and sometimes that requires a confirmation.

yes | program_that_requires_confirmation

read – get user input. In a shell script, you can assign this to a variable.

gnuplot – a command line program for creating graphs. It can be useful for research papers, which you might make graphs for in gnuplot and then put into a LaTeX document. There might be more advanced graphing tools out there, but the benefit of gnuplot is that it’s free and open source.

xxd – a hexdump/hex viewing tool. If you want to view a file as hexadecimal, use xxd. On macOS, I like Synalyze It! Pro, which in my opinion is a good hex editor. There are other options for Windows and GNU/Linux though, such as Hexinator. Hex editors are useful for binary data formats, not text files. Synalyze It! Pro lets you see which parts of the file correspond to which things, using things it calls “grammar” for file types. For example, you can see JPEG file headers, metadata, and things like that. Instead of viewing a bunch of seemingly random hexadecimal values, it tells you what each part belongs to. You can also change the file. Hex editors are useful for information security and malware analysis if that’s something you ever want to get into. Some people don’t, but for some people, that’s their true passion.

dmesg – a tool for viewing information about how the system booted up and some additional messages afterward. It’s a good idea to look at dmesg if you’re having system instability. dmesg requires being run with elevated privileges, such as using sudo dmesg

diff – a tool for comparing two files to see the differences between them. If you use git for version control when you’re developing software, you might use git’s implementation of diff. I use that much more than just a local diff tool.

md5 – a tool for finding the md5sum, a type of checksum, for a file. md5 is faster, but also less secure than other checksum algorithms.

md5 myfile.txt

One-way function – a one-way function is something that is trivially easy to do one way, but monumentally difficult (if not impossible) to do the other way. f(x) = x + 5 is not a one-way function because it’s easy to subtract 5 from x. Hashing algorithms use one-way functions. It’s easy to add sugar to coffee, but it would be very difficult to try and get all the sugar out of a cup of coffee (without taking anything else out).

Checksum – taking a huge file and turning it into a small string of characters as a quick way to compare integrity of things. It can be used for verifying file integrity or looking up files on something like VirusTotal to see if the checksum is in a database of known malicious files. If two files are the same, they will have the same checksum. For security, some sites list checksums of their software releases, so you can compare the checksum of what you downloaded to the known safe checksum. If it’s not the same, it could be a trojanized version of the program instead of a legitimate version.

Checksum collision a.k.a hash collision– when two different files have the same checksum. Checksum collisions are a potential security issue, because if you can get a malicious file to have the same checksum as a legitimate one, then people might trust it even when they shouldn’t. Hash collisions also come up with data structures like hash tables or hash maps.

shasum – a more secure method of computing a checksum, but it takes longer than md5.

nslookup – a tool for looking up information about a domain.

nslookup www.google.com

whois – look up registration information about a website. If you make a website, you need to use some service that hides your whois information, such as DomainsByProxy or WhoisGuard. Otherwise, personally-identifiable information such as your name, address, phone number, and email address can be visible to anyone who looks up the whois info on your site. All whois data is public. Personal websites without whois-protecting services will list a single person’s contact information, but an organization’s site might have less personal info for the business itself rather than an individual. Some whois information is only accessible via a browser, because if you use the command line whois tool, some registrars prevent that data from being seen that way. This is to stop automatic harvesting of information. So you sometimes have to go to a domain registrar’s website, like godaddy.com, and it might ask you to fill out a captcha or something to prove that you’re not a robot.

whois arstechnica.com

I remember seeing a security researcher showing a lot of incomplete phishing websites because they paid for some service that allowed them to view newly-registered domains. So you could see all these fake sites that would try to steal iCloud or Outlook accounts, but they were still under construction as they had only just purchased the domain name. It was amusing. Phishing is a serious problem though.

links – a text-only web browser. You can run it in a terminal or even over an SSH session. However, it is limited in usefulness, because many sites are intended to be viewed with a graphical browser. Some people will use it to try and look like a hardcore hacker though, even though it’s nothing more than a browser with no graphics. You will find that there are a lot of command line things like that – some that are useful, and some that people use to get a certain aesthetic quality on their computer, to look more technical or whatever.

busybox – a program that contains many command line tools within it. If you’re on an Android phone and want to use a lot of Unix utilities, try installing the Termux app and then installing busybox within Termux. Then your smartphone can act more or less like an ARM Linux machine, albeit with limited privileges (unless you root your phone). Android is based on Linux, after all.

Symlink – short for symbolic link. A link to a file. A symlink isn’t the original file; it just points to it. If you’re familiar with Windows, you’ve probably dealt with shortcuts, which are similar.

TTYs – a way to have multiple workspaces in Linux is to use different TTYs. TTY means TeleType, and a TTY in Linux means a virtual TTY terminal (as opposed to real terminals from back in the day, which were physical devices that would connect to a remote server). There are different ttys, like tty1, tty2, and so on.

These days, they aren’t that necessary, as modern DEs (Desktop Environments) allow for multiple virtual workspaces in the same TTY. But if you want to mess around with different TTYs, and do some CLI-only stuff with no GUI at all, you can hit ctrl+alt+f1 through ctrl+alt+d6 to cycle between TTYs. You will usually be presented with a text-only login, no GUI running. I guess it makes you look 1337 (slang for “elite,” meaning tech-savvy), but there isn’t much practical purpose for this stuff anymore.

If you have a Linux VM in something like Virtualbox, you hit right ctrl+f1 (or whatever function key for the tty you want).

In one of my Ubuntu VMs, the GUI stuff is in tty2, though it might be different for you.

If your computer is too slow to run both its own OS (such as Windows or macOS) and a graphical version of a Linux distro, you can possibly make it run a little faster by only using a tty that has no X server (graphical user interface). When you see someone mentioning X, x.org, xorg, X11, or X server, they are referring to GUIs in Linux. An alternative to X11 is Wayland.

← Previous | Next →

Command Line Topic List

Main Topic List

Leave a Reply

Your email address will not be published. Required fields are marked *