Just Starting in the Linux Terminal? Here Are Some Setup Tips
Linux & macOS Terminal
Quick Links
-
Pick a Color Scheme
-
Consider Transparent Terminals
-
Customize Your Prompt
-
Try Tabbed Terminals
-
Have a Backup Terminal Handy
-
Try a Terminal Multiplexer
The Linux terminal is useful, but it sometimes gets a bad rap for being boring. If you’re brand-new to using the command line, here are some ways to make it more useful, fun, and stylish.
1 Pick a Color Scheme
You’ll want your terminal to be readable since you’ll be spending a lot of time in it. Most Linux terminals are set up with a dark-on-light or light-on-dark scheme.
An alternative is a “solarized” scheme that aims for colors that are more pleasing to the eye for long sessions.
Your terminal emulator will often have a section in the settings with some predefined color schemes. You can start there and then tweak the settings until you find something you like, even if you only have 16 colors to choose from.
2 Consider Transparent Terminals
On many modern Linux terminal emulators, you can change the transparency of the terminal background. You can use it to pretend you’re a hacker in a 2000s police procedural, but it also has a practical purpose. If you’re working through a tutorial like the kind you can find on How-To Geek, you’ll be able to see what you’re doing more easily.
If you have a terminal window on top, you’ll be able to read the text that’s below the window. This will save you a lot of time and effort clicking between windows.
3 Customize Your Prompt
With Linux shells, you can customize your prompt to show useful information on each command line. On most shells, this is done by setting an environment variable.
In Bash, the variable you’ll want to set in the PS1 variable. This controls the prompt as shell level 1, which is the default when you’re at the command line.
In this variable, you can have any text you want, but you can also set some escape sequences with the “” character that will display other useful information
Some of these include:
u |
Displays your username |
w |
Shows your current working directory, with your home directory abbreviated with a ~ (tilde) character |
h |
display the hostname of your Linux machine up to the first “.” character. will display the full hostname. |
H (capital H) |
Your full hostname |
t |
Displays the time in 24-hour hour, minute, second forma |
T (capital T) |
Same as t, but in 12-hour time. |
Here’s how to put it all together. If you have an account on a remote Linux machine, it’s useful to know which machine you’re logged into to make sure you don’t confuse your local machine with the remote machine.
Open up the file .bashrc in a text editor and enter this line in it:
export PS1="u@h:w$: "
Save the file and either open a new terminal window or type this command at the shell to activate your new prompt
source .bashrc
At each prompt, you’ll see your username followed by an “@” character, followed by the hostname up to the first “.”, then your current working directory, followed by a “$” when you’re logged in as a regular user, but a “#” if you’re root, followed by a space.
Your distro might have come with a customized prompt with this kind of information already. You can leave it. It’s also possible to put colors in your prompt, and your distro also probably set a default with that too. Even though the syntax might be ugly, it’s possible to dig into it if you really want to trick out your prompt.
4 Try Tabbed Terminals
A useful feature on modern terminal emulators is tabbed terminals. This is similar to tabbed browsing. If you have so many browser tabs you forgot what you opened them for, you can finally bring this experience to the Linux terminal.
Many terminal emulators will have a button that looks like a plus sign or something similar to open a new terminal tab. Or you can go to the menu and select the option for a new tab. There will also frequently be a keyboard shortcut to open a new tab, like Ctrl+Shift+T.
On many terminal emulators, you can drag off a terminal tab into a window, and drag them back onto other terminal windows to make tabs.
5 Have a Backup Terminal Handy
When I make customizations in my terminal startup files, I like to have a window open with the current settings as a backup.
If I make an error in one of these files, it can make it impossible to open another terminal. I’d have to log in as root, delete the offending file in my home directory and start over again. With the alternate terminal, I have a terminal running that’s in a known good state. I keep this terminal open and then test my changes in another terminal window or tab.
It’s also a good idea to make a backup copy of any files you edit, such as your .bashrc, with the cp command:
cp .bashrc .bashrc.bak
If you make a mistake, you can just copy this backup copy over the file and you’ll be back where you started:
cp .bashrc.bak .bashrc
6 Try a Terminal Multiplexer
As useful as the Linux terminal is, you can make it even better with a terminal multiplexer. A terminal multiplexer, such as GNU Screen or tmux, allows you to run many shells and split the screen, much as you can with tabbed terminals or multiple terminal windows.
One advantage of terminal multiplexers is that you can suspend a session and resume it. This is handy on remote SSH connections. If your Wi-Fi connection drops while you’re connected, when it comes back up, you can log back in and resume what you were doing.
Now that you’ve got the perfect terminal setup, start learning to use it with some basic Linux commands for beginners.