PROWARE technologies
PROWARE technologies

Linux Administration Guide

This primarily discusses the options available to Ubuntu Linux server administrators. Have the operating system installed and then be logged in.

The "sudo" Command

The sudo command is used to run commands with super user rights. Alternatively, to prevent having to use sudo all the time login in as the root user by issuing a sudo -i or sudo su command. To logout of the root user account issue a exit command. exit again to logout the current user. Sometimes it is neccessary to be logged in as root.

On some Linux distributions, login as root with su -nd then enter the password for root. Now, run all the following commands in this guide without sudo.

Changing the Computer's Clock

To change the computer's clock, issue sudo hwclock --set --date "10/31/2017 24:00:00" and then to see the time it is set to hwclock --show. Notice: there is no hardware clock in the Raspberry Pi.

Common Commands

Using the Text Editor "nano"

Issue a sudo nano file.txt command to edit a text file or create a text file. There is a menu of options at the bottom of the screen.

The "ifconfig" Command

Use the ifconfig command to display all the networking interfaces installed in the computer including localhost (also known as lo). Change the IP address by issuing a sudo ifconfig eth0 192.168.1.2 command. Change the netmask by issuing a sudo ifconfig eth0 netmask 255.255.255.0 command. Change the broadcast by issuing a sudo ifconfig eth0 broadcast 192.168.1.255 command.

Setting the Nameserver

Use sudo nano /etc/resolv.conf to edit the IP addresses for the nameservers.

nameserver 192.168.1.1
nameserver 194.63.248.47

Static IP Addresses

Login as the root user and issue a nano /etc/network/interfaces command to edit the network interfaces to use a static IP address.

# The primary network interface
auto eth0
iface eth0 inet static
	address 192.168.1.2
	netmask 255.255.255.0
	network 192.168.1.0
	broadcast 192.168.1.255
	gateway 192.168.1.1
	dns-nameservers 192.168.1.1
	dns-search lan

The "less" Command

Issue a dmesg > outputdmesg.txt command then issue less outputdmesg.txt. This will allow reading of the entire file as it is too big to fit on the screen. q to quit the program.

Compressing/Decompressing Files with "tar"

To view the contents of a compressed archive tar tzf archive.tgz or if it is a very large archive then tar tzf archive.tgz | less. To create an archive tar czf archivefilename.tgz directoryname. To decompress an archive tar zxf archive.tgz.

The "man" Command

The man command is used for reading online manuals. Execute man man to read the manual for man.

Using "cron" to Repeatedly Execute Jobs

The cron daemon executes a task frequently. Users listed in the cron.deny file aren't allowed to use cron and users listed in the cron.allow file are allowed. The root user can always set jobs. Learn more by issuing a man cron command.

Firewall

To enable the firewall, issue a sudo ufw enable command. To enable a port through the firewall, issue a sudo ufw allow 587 command. To delete the same port, issue sudo ufw delete allow 587. Learn more by issuing a man ufw command.

Updating the Server

Issue sudo apt-get update, sudo apt-get upgrade -y and sudo apt-get dist-upgrade -y commands. This will update the server software (if it needs it).

Installing/Uninstalling Software

Installing and uninstalling software is done with the sudo apt-get install and sudo apt-get remove commands. For example, to install MySQL database server issue the sudo apt-get install mysql-server command. To remove it sudo apt-get remove mysql-server.

Alternatively, a much simplier method is to use sudo tasksel and then simply check (with the space key) what it is that you want installed or uninstalled. If tasksel is it not available then install it with the command sudo apt-get install tasksel.

Apache Server

Install Apache web server using the sudo tasksel command. Use the LAMP install option. Or, issue a sudo apt-get install apache2 command. Check the version of Apache that is installed on your server with the command /usr/sbin/apache2 -v.

/etc/init.d/apache2 status shows the current status (running or not). sudo /etc/init.d/apache2 start will start Apache. sudo /etc/init.d/apache2 stop will stop Apache. sudo /etc/init.d/apache2 restart will restart Apache.

Configuration Files and Directories

Samba Server

Install Samba server using the sudo tasksel command or a sudo apt-get install samba samba-common-bin command.

Share a directory by editing the configuration file with the sudo nano /etc/samba/smb.conf command. Page down to the #=== Share Definitions === section and add these lines:

[www]
path=/var/www/html
writable=yes
browseable=yes
only guest=no
create mask=0777
directory mask=0777
public=yes
guest ok=yes

Save the file and then issue a sudo chmod 0777 /var/www/html command to set file permissions. Restart the server with sudo service smbd restart and sudo service nmbd restart. Browse to the network on a Windows machine and the server should be listed with its new share, www, of the web server's home directory.

Now, learn how to install and setup a Ubuntu mail server.

Contact