Getting Started
Overview
This page should contain the basic information needed to anyone starting out using a Linux server. Much of this information has been compiled from other guides, but I have rewritten and reformatted the content to be more readily available. Some of the content here was referenced from sources such as the Linux Filesystem Hierarchy Standard (Linux FHS).
Basics
We'll start with using the terminal for basic tasks we usually do with GUIs in full desktop environments.
Searching for packages
sudo apt search "Dell XPS 13 9300"
Sorting... Done
Full Text Search... Done
oem-somerville-factory-melisa-meta/unknown,unknown,now 20.04ubuntu12 all [installed]
hardware support for Dell XPS 13 9300
oem-somerville-melisa-meta/unknown,unknown,now 20.04ubuntu12 all [installed]
hardware support for Dell XPS 13 9300
Installing packages
sudo apt install oem-somerville-melisa-meta
Updating package registry and upgrading installed packages
sudo apt update && sudo apt upgrade
Updating package registry, upgrading packages, removing unused, fixing broken installed packages
sudo apt update -y && sudo apt upgrade -y && sudo apt upgrade --fix-broken --fix-missing --auto-remove
Checking system resources
htop
Checking Battery Consumption
sudo powertop
Connecting to WiFi
sudo nmcli device wifi list
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY
* 40:B8:9A:D7:EC:AF FAKE WIFI-2G Infra 1 195 Mbit/s 100 ▂▄▆█ WPA2
40:B8:9A:D7:EC:B0 FAKE WIFI-5G Infra 149 405 Mbit/s 94 ▂▄▆█ WPA2
FA:8F:CA:95:43:9B Living Room Infra 6 65 Mbit/s 75 ▂▄▆_ --
FA:8F:CA:82:9D:D4 Family Room TV.b Infra 6 65 Mbit/s 57 ▂▄▆_ --
14:ED:BB:1F:44:6D Hi Infra 8 130 Mbit/s 57 ▂▄▆_ WPA2
14:ED:BB:1F:44:76 ATT9eu7M6L Infra 149 540 Mbit/s 44 ▂▄__ WPA2
4C:ED:FB:AD:D8:08 Fluffymarshmellow Infra 1 540 Mbit/s 30 ▂___ WPA2
70:77:81:DE:43:59 WIFIDE4355 Infra 1 195 Mbit/s 24 ▂___ WPA2
70:5A:9E:6C:D4:29 TC8717T23 Infra 6 195 Mbit/s 19 ▂___ WPA2
A8:A7:95:E8:68:82 Wildflower-2G Infra 1 195 Mbit/s 14 ▂___ WPA2
CC:2D:21:57:E0:71 Rudy Infra 6 130 Mbit/s 14 ▂___ WPA1 WPA2
CE:A5:11:3C:E4:C2 Orbi_setup Infra 9 130 Mbit/s 14 ▂___ --
A8:6B:AD:EB:B4:56 Gypsy-2 Infra 6 195 Mbit/s 12 ▂___ WPA1 WPA2
CE:A5:11:3C:EF:8E Orbi_setup Infra 9 130 Mbit/s 12 ▂___ --
Now bring up a connection with the access point we want, and pass the --ask
flag to enter a password for authentication.
sudo nmcli c up "FAKE WIFI-2G" --ask
Passwords or encryption keys are required to access the wireless network 'FAKE WIFI-2G'.
Password (802-11-wireless-security.psk): •••••••••••••••••••
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)
Disable transmission devices with rfctl
sudo rfkill list
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
1: hci0: Bluetooth
Soft blocked: yes
Hard blocked: no
Block WiFi
sudo rfkill block wlan
Block Bluetooth
sudo rfkill block bluetooth
Creating a User
sudo adduser username
Granting sudo to a user
sudo usermod -G sudo username
Resetting a user's password
sudo passwd username
Logging out of our user session, where kapper
is my username.
sudo pkill -KILL -u kapper
Rebooting
sudo reboot now
Man Pages
When encountering issues with Linux servers, its important to know how to gather specific information from credible resources quickly via tools given to us within our Bash terminal. One of these tools is known as the man pages - this set of documentation is not only well maintained and credible in its content but also readily available to us from any terminal.
Local Storage Location
These pages are usually stored locally within /usr/share/man/
where they can be updated as new packages are released and documentation changed. These local files allow us to reference the man pages offline should we disconnect from the internet, and also within /usr/share/man/
you will see locale named directories - these are simply housing different language man pages should you need to reference them. See the example output below when we check the contents of /usr/share/man
ls /usr/share/man/
cs/ es/ hu/ ja/ man2/ man5/ man8/ pl/ ru/ sv/ zh_TW/
da/ fi/ id/ ko/ man3/ man6/ man9/ pt/ sl/ tr/
de/ fr/ it/ man1/ man4/ man7/ nl/ pt_BR/ sr/ zh_CN/
Directory | Content Category |
/usr/share/man/man1 | User programs |
/usr/share/man/man2 | System calls |
/usr/share/man/man3 | Library calls |
/usr/share/man/man4 | Special files |
/usr/share/man/man5 | File formats |
/usr/share/man/man6 | Games |
/usr/share/man/man7 | Miscellaneous |
/usr/share/man/man8 | System administration |
/usr/share/man/man9 | vmxnet.9.gz |
Contents of these directories are optional depending on system and distribution
This may seem like besides-the-fact information - but it's good to know where these files are stored and to step through the locations yourself so you know what resources you have available to you. I would urge anyone interested to check out the contents of these locations from your own system, and then view the man pages associated with some of the topics that stand out to you. This should be relatively easy to do, but for completeness, the below is an example of checking a directory and then viewing the man page of topic I found within it. You will not see the man page in the example below, as it is ran within the active terminal.
ls /usr/share/man/man4
cciss.4.gz initrd.4.gz mem.4.gz random.4.gz vcs.4.gz
console_codes.4.gz intro.4.gz mouse.4.gz rtc.4.gz vcsa.4.gz
cpuid.4.gz kmem.4.gz msr.4.gz sd.4.gz veth.4.gz
dsp56k.4.gz lirc.4.gz null.4.gz smartpqi.4.gz wavelan.4.gz
full.4.gz loop-control.4.gz port.4.gz st.4.gz zero.4.gz
fuse.4.gz loop.4.gz ptmx.4.gz tty.4.gz
hd.4.gz lp.4.gz pts.4.gz ttyS.4.gz
hpsa.4.gz md.4.gz ram.4.gz urandom.4.gz
man console_codes
Indexing Pages
When viewing the manual pages, the amount of information can be overwhelming at times and it is easy to miss subtle things that could prove very useful in a situation where information on a topic is otherwise scarce. We should note that there can be sections to a manual entry for any given package, these sections are indexed according to the number of the corresponding category that the referenced package subtopic falls under. Its really useful and easy to understand once you work with it a bit. See the commands below, where we check for all man pages associated with whatis intro
, and then look for the correspondence in the Local Man Page Storage table above.
whatis intro
intro (1) - introduction to user commands
intro (2) - introduction to system calls
intro (3) - introduction to library functions
intro (4) - introduction to special files
intro (5) - introduction to file formats and filesystems
intro (6) - introduction to games
intro (7) - introduction to overview and miscellany section
intro (8) - introduction to administration and privileged commands
find /usr/share/man/man* -name intro*
/usr/share/man/man1/intro.1.gz
/usr/share/man/man2/intro.2.gz
/usr/share/man/man3/intro.3.gz
/usr/share/man/man4/intro.4.gz
/usr/share/man/man5/intro.5.gz
/usr/share/man/man6/intro.6.gz
/usr/share/man/man7/intro.7.gz
/usr/share/man/man8/intro.8.gz
So, the intro manual pages proves to be a perfect example since its easy to relate this information to our table above. Below, we ask whatis time
whatis time
time (1) - run programs and summarize system resource usage
time (7) - overview of time and timers
time (3am) - time functions for gawk
Then look into the results by running man <PageID> time
where <PageID>
corresponds with the page we'd like to view.
user@knoats:~$ man 3am time
We see that the information is organized as we expect, having researched the Local Man Page Storage above. The first section, time (1)
, is a man page for the time command and how to use it when running user programs. The next section, time (3am)
, The final section, time (7)
, is a general overview of time and timers within Linux.
Text Editor
You will need to edit text when working in Linux, and a popular and powerful tool for doing so is vim. Vim can be a tricky program to use at first, but there are resources available to help teach vim to newcomers. There is even a commandline tutor that will walk you through vim from within the default viewport of a terminal using interactive text tutorials. to run this tutorial, simply run vimtutor
from any Linux commandline. I would elaborate more on this topic, since it is such an important tool within Linux Server Administration - but there are plenty of tools and resources out there that offer much more information. Instead, I'll link to some good information here. Or, if you don't have immediate access to a terminal, check out a quick google search for some vim interactive tutorials and you're sure to find some games available to teach you within a web browser.
Plugins / Enhancements | |
Syntax Checker for Vim | https://github.com/vim-syntastic/syntastic |
Snippets | https://github.com/SirVer/ultisnips |
Vim Solarized | https://github.com/altercation/vim-colors-solarized |
Code Completion | https://github.com/ycm-core/YouCompleteMe |
Git Plugin | https://github.com/tpope/vim-fugitive |
Auto Configuration Tool | https://github.com/chxuan/vimplus |
Community Vim Distribution | https://github.com/SpaceVim/SpaceVim |
Everything Else | https://github.com/mhinz/vim-galore |
No Comments