Linux for Windows Server Admins
Create and Add Users
Add the user by typing in useradd followed by the desired login name to create. An example would be useradd sburns. This will follow with a few questions to answer and finally create the user. You should now be able to login with PuTTY. Once logged in as the nonprivileged user, the administrator can elevate their privileges to root.
Using su – will allow a user to switch between users, even root, as long as the user knows the relevant password. The command itself is shorthand for “switch user.” As root an administrator can change to any other user by using the command su simon (or su bill or whomever), assuming the password is known. The “-” switch is used to give all the environmental variables. Using su – without specifying a user will assume you want to switch to the root user. There is a file called /etc/sudoers that holds the configuration for su.
So now we are logged in, lets cover some rudimentary file system-related items. When logged in as a normal user, they would initially be placed in their home directory that was created when the user was created, as was shown before. Move about the system using the command cd, the same as Windows, but remember that Linux is case sensitive.
Using the Linux CLI
With Linux, the backslash becomes a forward slash. To return to your own home directory at any point, just type cd without any arguments. If you are also not sure where you are in the file structure, there is a command called pwd. This command will give the full path to your current location. This is a very useful command, especially if you have many windows open – and double check before using potentially dangerous commands!
Managing Drives with Linux
Linux has no concept of drive letter mappings. Instead drive letters map to what are known as mount points. A very rudimentary example is with CD ROM drives. In Windows, when a CD is inserted, it is mounted as a drive letter. For example, E: This differs in Linux because when you mount a CD, it essentially links the contents of a CD to a folder. Something to bear in mind is that as a rule Linux machines do not auto mount media.
An administrator would have to mount the CD and link it to a folder. Most modern Linux distributions come with a media folder for this purpose. To mount a CD, use the commandmount /dev/cdrom /media. Similarly, to dismount a disk, use the command umount /media. This mounting method is not only for CDs but also for USB sticks, hard disks, and most other media, albeit with some occasional options to specify file systems and such.
To see what is mounted currently, type the command mount. Standard mounts are stored in the file /etc/fstsab. You can modify this file to add additional mount points if you wanted to add additional storage systems at boot. Pro tips: First, make sure you have a backup (use the command cp /etc/fstab fstab.bak). Second, use the mount -a command to verify the fstab file is still valid before you reboot it and find that it isn’t!
Now it might be a good time to introduce you to how most Linux installations are organized from a file and directory perspective.
- / – root, as in the top level of the disk
- /home – where users home directories and personal data are located
- /boot – contains important boot files. You will rarely need to go in here
- /dev – contains pseudo devices that link directly to the hardware
- /root – the roots home directory, and where a root can store its files
- /etc – contains all the configuration files for pretty much everything: networking, services, and some applications
- /mount – This folder is used to mount NFS mounts and removable media
- /var – Contains many system components, logs, and miscellaneous
- /proc – Holds information about running processes.
- /bin – Contains program files
- /sbin – Contains system administration binary files
Useful Linux CLI Commands
When working with files, there are some useful commands you can run to help you manage them, as Linux doesn’t tend to do file extensions. If you want to know what type of file you are looking at, you can use the command file file, and it will interrogate the file and provide all the information it can gather.
To view human readable files, you can use the cat command. To edit a file, use the nano editor (for example, nano filename).
If you need to find a file, you can use the locate command. For example, to locate redhat-release (This file holds the release information for the RedHat Build) use the command locate redhat-release.
Other useful commands we can use right now are df, which gives disk space statistics. Usingdf -h may prove a better option as it gives sizes in human readable form of megabytes, gigabytes, and such, rather than an unwieldy size in bytes.
If you want to change your password now, you can use the command passwd. Used without any switches, it will allow you to change the password of the user you are logged in as. If you are logged in as root, you can change other people’s passwords by using the passwdcommand, followed by the username. An example would be passwd stuart.
It is also possible to edit the user setup by use of the command usermod. This will allow you to manage and modify settings on a per-user basis; for example, changing the username or home directory.
via Linux for Windows Server Administrators.