Introduction
I've been a Windows user for as long as I can remember. My first computer was an MS-DOS system running Windows 3.1. From there it was a short trip to 95, 98, Me (sadly), XP, and Windows 7. I was fortunate enough to skip Vista and 8. Of course my new job requires me to spend most of my time in Linux configuring servers -- Linux boxes without a GUI. I jumped in clueless. This is a guide for other Windows users learning how to remotely administer Linux servers.
First Steps
I've written this guide with Debian and it's derivatives (like Ubuntu) in mind. Most hosting companies offer Debian servers. This guide may still be helpful for other Linux flavors, but you’ll need to do some additional googling.
If you're like me, you were probably just given an IP address and a login for something called "ssh" (read more here). You’ll want to download a program called PuTTY and install it. Enter the IP address and click "Open."
If everything went as planned you’ll be given a new console window asking for your login. Go ahead and enter the information you were given. Soon you’ll be logged in.
You’ll probably want to change your password:
passwd
(Just type it and hit enter.)
Make sure you enter something good. This is your only defense against attacks. You can also change the password of other users by typing:
passwd username
Users
Speaking of users, you may want to create a few new users. The command is pretty easy, but you will have to assign roles and passwords to each user.
useradd username opts
passwd username
If you want to allow a user complete control for administration use
useradd username sudo
passwd username
You can also grant an existing user sudo access. Ubuntu allows the following command.
usermod -a -G sudo username
Otherwise try manually opening the sudoers file and editing it. You’ll be using a special vi derivative to edit it. Check the section on vi / vim use.
visudo -f /etc/sudoers
Add the following line
username ALL = (ALL)ALL
Basic Console Commands
These commands usually work on Windows too, but they might be just a bit different. You’ll likely be spending a lot of time using these commands as you navigate the filesystem.
cd - change directory
command changes the directory your terminal is running on. Unlike Windows there are no drive letters in Linux so you’ll never have to use a command like "e:" before a cd command.
Common Uses:
cd ~/
- Takes you to your home directory. Think of this a little like your Windows user folder.
cd /
- Takes you to the file system root.
cd ../
- Takes you back one folder. Use ../../ to go back two and so on.
Pair with pressing "Tab" to find directories. For instance, if I start typing /longfilenamefolder/ I can press tab after the first few letters to have the operating system enter the only matching directory. I find myself entering things like cd /e Tab /ng Tab /s Tab -a Tab Enter
. (That, by the way, takes you to the sites-available folder of an NGINX install.)
more information - http://ss64.com/bash/cd.html
ls - list information
gives information about a file OR lists the contents of your current directory. I usually use it for the second. Let’s say you run cd /etc/ but aren’t quite sure what you’re looking for. You can then run ls to get a list of that directory's contents.
more information - http://ss64.com/bash/ls.html
mkdir - make directory
create a new directory in the current terminal path.
Common Uses:
mkdir directory name mkdir /path/to/new/directory/directory_name_to_create
more information - http://ss64.com/bash/mkdir.html
rm - remove / delete
permanently deletes a single file.
Common Uses:
rm filename
- delete a file.
rm -f filename
- force the file to be deleted.
rm -Rf filename
- remove a directory and all of its contents recursively
more information - http://ss64.com/bash/rm.html
mv - move or rename
Moves a file. If the resulting file is in the same directory as the original file it will be renamed.
Common Uses:
mv old-file-name new-file-name
- renames or moves a file.
mv -i old-file-name new-file-name
- renames or moves a file, prompting the user before overwriting information.
Articles in Series
Future Articles In Series
- Linux File Structure
- Managing Packages
- Interesting Commands