Category Archives: Linux Mint 15

Linux Mint 15: Change File And Directory Permissions With chmod

Mintifconfing

Newcomers to Linux in general, and Linux Mint 15 in particular, are often confused by the way file permissions work. They’re really quite simple, but can interact in complicated ways. Here, then, is quick guide to Linux permissions.

To start, go to a command prompt and type this command:

ls –l

The ls command lists the contents of the current directory, and the –l switch adds the long listing. You’ll probably see a bunch of entries that look like this:

-rwxrwxrwx 6 bobsmith users 4096 Dec 9 14:56 test.txt

The “rwxrwxrwx” details the permissions on the “test.txt” file.

The “R” means “read”. This gives permission to view the contents of a file, but not to alter it in any way.

The “W” means “write”. This gives permission to change a file or to delete it.

The “X” means “execute”. This gives permission to run the file as an executable file. If you want to run an executable file or shell script, it HAS to be marked as executable.

So if a file’s permissions are marked “rwx”, that means it can be read, it can be written to/deleted, and it can be executed.

Now, you might be wondering why the “rwx” repeats three times. This is because each file and directory has three sets of permissions: one for the file’s owner, one for the owning group, and one for everyone on the system. The “ls –l” command reveals the file’s owner and owning group; in the case of “text.txt”, they are “bobsmith” and “users”.

You can use the “chmod” command to change the file’s permissions. For instance, to add the write permission to everyone, use this command:

chmod a+w test.txt

Or to add the execute permission to the file’s owner, use this command:

chmod u+x test.txt

It is, however, easier to express the file permissions using numbers. Each permission has a number assigned to it; “R” gets 4, “W” gets 2, and “X” gets 1. The permissions are then added up to determine the effective permission. For instance, if the file’s owner has a permission of 6, that means he can read the file, write to or delete it, but he can’t execute it as a program.

The same scheme applies to group and everyone permissions on the same file. For instance, from the example above:

rwxrwxrwx

That can be expressed as this:

777

Needless to say, this makes using the chmod command far less cumbersome. Let us say you wanted to change test.txt’s permissions so that the owner can read, write and execute, the owning group can read and execute, and everyone on the system who is neither the owner nor the owning user can read the file but not write or execute. You would use this chmod command:

chmod 754 test.txt

-JM

ADDITIONAL READING:

The Linux Mint Beginner’s Guide

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

Linux Mint 15: Release And Renew DHCP Addresses With dhclient

Mintifconfing

On a Linux Mint 15 system with a DHCP address, releasing the IP address and obtaining a new one is quite simple. (This is often useful with troubleshooting network problems).  To release a DHCP IP address, go to a Terminal window and type this command:

sudo dhclient -r

(Note that you must use dhclient either as root or with the sudo command for it to work.)

This will release your current IP address. To obtain a new one, use the dhclient without any arguments:

sudo dhclient

Assuming that dhclient can reach a DHCP server, your system will receive a new IP address in short order.

-JM

ADDITIONAL READING:

The Linux Mint Beginner’s Guide

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

Linux Mint 15: Install Samba Web Configuration Tool

SambaSWAT

It’s relatively easy to configure Samba using command-line tools and by editing the /etc/samba/smb.conf file. However, the learning curve is rather sharp. If you want a more graphical interface, there’s a program called SWAT, the Samba Web Administration Tool. SWAT allows you to administer your Samba server through a web interface. SWAT is a fairly complicated program to install on Linux Mint 15, but once you have it up and running, it’s quite simple to use.

First, you’ll need to have Samba installed before you can install SWAT.

Once you have Samba installed, you’ll need to pick an account that is a member of the local admin group, since you’ll need an account with admin-level permissions to use all of SWAT’s functions (otherwise you’ll only see status pages, and will be unable to change any settings). The default account you created during the installation of Linux Mint belongs to the local admin group, so that account will work. Make sure the admin group has permission to the /etc/samba/smb.conf file with these commands:

sudo chmod g+w /etc/samba/smb.conf

sudo chgrp adm /etc/samba/smb.conf

Next, install both SWAT and the inetd Internet superserver, which is required for SWAT to run properly (inetd is sort of a “super-process” that can control and call lesser processes):

sudo apt-get install swat xinetd

This will install SWAT and the inetd superserver, and their dependencies. Once the installation has finished, you’ll need to create a configuration file for SWAT in the /etc/xinetd.d directory. Fortunately, you can do that quite handily with vi:

sudo vi /etc/xinetd.d/swat

Once you’re in the swat file, switch vi to Insert mode add this text:

# default: off

# description: SWAT is the Samba Web Admin Tool. Use swat \

# to configure your Samba server. To use SWAT, \

# connect to port 901 with your favorite web browser.

service swat

{

port = 901

socket_type = stream

wait = no

# Use only_from if you want to restrict access

# only_from = localhost

user = root

server = /usr/sbin/swat

log_on_failure += USERID

disable = no

}

Note that there must be a space before and after the equal signs.

After you’ve added the text, switch back to Command mode, save the file, exit vi, and use this command to restart the inetd server:

sudo /etc/init.d/xinetd restart

From a different client on your network, fire up a web browser. Assuming your Samba server has an IP address of 192.168.1.2, you can access SWAT here:

http://192.168.1.2:901

Enter a username and a password from the admin group, and you’ll have access to SWAT.

Note that SWAT also includes all of Samba’s man pages in easily-read web page format.

-JM

ADDITIONAL READING:

The Linux Mint Beginner’s Guide

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

Linux Mint 15: Install MySQL Server

MintRoute

To install MySQL Server 5.5 on Linux Mint 15, make your way to a Terminal window or a command prompt, and type this command:

sudo apt-get install mysql-server-5.5

(As of this writing, MySQL Server version 5.5 is the latest version available in the repositories, though future versions of Linux Mint may receive the newer versions of MySQL.)

Enter your password to authenticate, and apt will download the MySQL files and install them for you. It’s a big set of files, so depending on the speed of your Internet connection, it might take a while to download. After the files are downloaded and are installing, the installer will ask you for a password for MySQL’s root user. Just like the root user in Linux, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you’ll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.

(Note that in the password dialog box, you can’t get the <OK> field selected, you can use the tab key to jump from the text input line to the <OK> field.)

After you enter the root password, the installer will finish working with the MySQL files, and return you to the command line. You’ll then need to activate MySQL with the following command:

sudo mysql_install_db

This will set up MySQL Server for use with your Linux Mint system. Next, you’ll want to run the mysql_secure_installation script to tighten up security on your new MySQL server. Run this command from the prompt:

sudo mysql_secure_installation

First, the mysql_secure_installation script will ask you to enter the current password for the MySQL root user. After you do that, it will ask if you want to change the root password. Since you already set a root password, you can hit “n” (unless you want to change it again for some reason).

Next, the script will ask if you want to remove the anonymous user. The anonymous user, like anonymous access in FTP, lets someone log into MySQL without having a proper user account. For security reasons, it’s always best to remove the anonymous user, so hit “y” to continue.

After that, the script will ask if you want to prevent the MySQL root user from logging in remotely to the MySQL server. Always hit “y” to forbid root remote access, since if an attacker guesses your root password, he can destroy your databases or steal the information they contain.

After this, the script will ask if you want to remove the test database. MySQL includes a test database that anyone can access. Again, this is a security hole, so you’ll want to hit “y” to remove the test database.

The script will then ask to reload the privilege tables so the changes take effect. Hit “y”, and the mysql_secure_installation script will conclude and return you to the command line.

MySQL server is now installed on your Linux Mint system. In the next section, we’ll discuss using the MySQL command-line client to create databases and users.

The most common use for MySQL on a Linux Mint system is to provide a backend for a dynamic website of some kind, usually content management systems like WordPress or MediaWiki. To host these websites on a Linux Mint machine, you’ll need to create a database and a database user for the website. MySQL Server can support many different databases, limited by the amount of hardware and disk space available on the machine. (Hosting multiple active databases at the same time places a high level of demand upon a hard drive.)

Like Samba, MySQL has its own collection of user accounts, separate from the main system accounts, called “database users.” A database user is simply a MySQL user that has access to a particular database, or specific tables within a database. In this section, we’ll show you how to create database and users with the command-line client.

First, you’ll need to get to the MySQL client prompt. The MySQL command-line client, like the command-line clients for FTP and SFTP, has its own prompt. To access that prompt and start the client, use this command:

mysql

However, if you simply type the command, it will bounce back with an error message. To use the MySQL command-line client, you need to add the -u and the -p switches as well. The -u switch tells it what MySQL user you want to use to log into the client (similar to the -l switch with SSH). The -p switch tells it to ask for the password. So, to use the MySQL client as the MySQL root user, the command should look like this:

mysql -u root -p

Enter the password for the MySQL root user, and you’ll find yourself at the MySQL command prompt, which will look like this:

mysql>

Our next steps are to create a database, create a user to access that database, and grant our new user all rights to that database. Generally, when you’re installing a web application like WordPress, you’ll give the database user you create for the WordPress application all rights to the database so it can function properly. Not giving the application user all rights to the database can cause the application to act erratically or even fail entirely (though some applications can work with limited access to its database).

An important note before we continue, though. All commands made from the MySQL prompt must end with a semicolon to denote the end of the statement. Any commands that do not end with a semicolon will not work. With that in mind, let’s first create a database.

To create a database, use this command at the mysql> prompt:

CREATE DATABASE newdatabase;

The MySQL client will respond with a message that should say “Query OK, 1 row affect (0.00 sec).” This means the command was successful, and a new database named “newdatabase” has been created.

Next, you’ll create a user who will access that database:

CREATE USER newdatabaseruser;

You should get the “Query OK” message again. Once the new user is created, we’ll need to set a password for the user before we can assign any permissions. In this example, we’ll assign a password of “1234″. However, in real life, just as with the root user, you’ll want to assign a strong password. (This database user won’t have full control over the MySQL user as the root user does, but we will give it full control over the database we just created, and a malicious user who guesses the password could cause all kinds of trouble.)  To create the password, use this command:

SET PASSWORD FOR newdatabaseuser= PASSWORD(“1234”);

Again you should get the “Query OK” confirmation message. The final step is to assign all privileges on the “newdatabase” database to the “newdatabaseuser” user. Use this command to assign the permissions:

GRANT ALL PRIVILEGES ON newdatabase.* TO newdatabaseuser IDENTIFIED BY ‘1234;

That isn’t a typo – those are single quote marks (‘) instead of the usual double quote marks (“) that were used in the command to set the password. MySQL’s internal syntax, alas, isn’t always consistent. Anyway, if you typed the command correctly, you should get the “Query OK” confirmation again.

Once you are done, use this command to quit the MySQL command-line interface:

exit

You’ve now set up a database, created a database user, and given that user full control over that database.

-JM

ADDITIONAL READING:

The Linux Mint Beginner’s Guide

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

Linux Mint 15: Check Disk Space Usage And Directory Size

SSHMint

Hard drives have gotten ever larger, but it’s still important to keep disk space usage under control. If you’re using a netbook with a small solid-state hard drive, then keeping disk usage under tight control is especially important. Fortunately, Linux Mint 15 has a number of easy Terminal commands for taking a quick look at your disk usage.

The first command is df, which will produce an output that will show you the various filesystems on your computer, along with the percentage currently used. However, the numbers shown are in 1k blocks, which may be difficult to read if you’re not used to it. Using df -h will produce an output that will have the sizes are sorted into gigabytes, megabytes, and kilobytes, making it much easier to read.

You can also use a Terminal command to check the size of an individual directory. For instance, if you wanted to check the size of your Documents directory, you would use this command:

du -hs Documents

This will give you the combined size of your Documents folder, along with any subfolders.

-JM

ADDITIONAL READING:

The Linux Mint Beginner’s Guide

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

Linux Mint 15: Create An FTP Server With vsftpd

vsftpd

FTP stands for “file transfer protocol”, and it allows you to transfer files to a remote computer. FTP has been around forever, and it has a number of pros and cons. Since FTP is so old, it is supported on virtually every operating system, and most operating systems include an FTP client of some kind. Linux Mint 15 can act as an FTP server with a reasonable degree of security. In this post, we’ll show you how to set up Linux Mint as an FTP server.

The most common FTP server software for Linux Mint is the vsftpd package, which stands for “very secure FTP daemon.” It’s the default FTP package for Linux Mint, and most other Linux distributions as well. As an added bonus, vsftpd is pretty secure out of the box – to make it insecure, you have to go out of your way to mess up the configuration file.

As an added bonus, vsftpd is simple to install and configure on a Linux Mint machine. To install the vsftpd package, make your way to a command prompt and type this command:

sudo apt-get install vsftpd

Enter your password to authenticate and apt will download and install vsftpd for you.

Follow the default prompts, and the vsftpd server will be installed on your computer. Generally, the default configuration for vsftpd is pretty secure, and good enough for casual use. Anonymous users are allowed, but no one can write files to the server (or, in FTP terminology, no one can upload files to the server). However, this configuration isn’t very good if you want people to be able to write files to the server, so we’ll show you how to securely set that up by changing vsftpd’s settings.

If you want to change any settings, the configuration file for vsftpd is /etc/vsftpd.conf. Like any other configuration file, you can edit it with vi:

sudo vi /etc/vsftpd.conf

The vsftpd.conf file contains a large number of “directives” that govern how the server behaves and operates. If you want to change its configuration, you’ll need to alter the directives.

If you want people with local user accounts on the FTP server to be able to connect via FTP (you usually do), you will need to change this directive:

#local_enable=YES

To this:

local_enable=YES

If you do not change this directive, only anonymous users will be able to log into your FTP server, which is bad. (More on that below.)

If you want users to be able to write files to your FTP server, change this directive:

#write_enable=YES

To this:

write_enable=YES

With the write_enable directive set to YES, users will be able to upload files to your FTP server. Note, however, that they will only be able to do so if they have proper permissions to the directories in question. They’ll be able to upload files to their home directories, but not, for instance /var or /usr.

Anonymous access is controlled with this directive:

anonymous_enable=NO

Under no circumstances should you allow anonymous access to your FTP server, especially if it is accessible from the Internet! There are certain circumstances when you might find it useful, but you should only enable it if you know exactly what you are doing. Generally, it is almost always best to keep anonymous_enable set to NO. Especially if you allow users to write files to your FTP server, then it is very important to have anonymous_enable set to NO.

If you make any changes to the file, switch vi to command mode, save the changes, and then exit vi. Then restart the vsftpd server so it reads its new directives:

sudo service vsftpd restart

Your Linux Mint machine should now have a functional FTP server.

-JM

ADDITIONAL READING:

The Linux Mint Beginner’s Guide

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

Linux Mint 15: Kill Processes From The Command Line

MintRoute

Linux Mint 15 is pretty stable. But nothing is perfect, and sometimes processes crash, hang, or lock up. Fortunately, it’s quite simple to use the Terminal command line to force processes to quit or restart.

Let’s say, for example, that gedit had frozen up. To kill the gedit process, you’d first need to know its PID, its Process ID Number. Every application and daemon on a Linux system receives a PID. To find gedit’s PID, use this command at the Terminal prompt:

ps -u USERNAME

(Replace USERNAME with your username, obviously.)

This will spit out a list of all the processes associated with your username running on the Linux Mint system. Find the “gedit” process and note its PID.

Once you have gedit’s PID, you can use the kill command to kill the process. (For the sake of the example, let’s say gedit has a PID of 1456):

kill 1456

This will force the gedit process to quit. If it doesn’t, try kill with the -9 switch:

kill -9 1456

This forces the gedit process to quit without giving it a chance to release its claimed system resources. To get the RAM gedit had claimed back, you might have to restart your Linux Mint system.

-JM

ADDITIONAL READING:

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Set Up A VNC Server And A VNC Client On Linux Mint 15

Mint15

In this post, we’re going to explain how to use your Linux Mint 15 machine as a VNC server. VNC is an extremely useful networking protocol that allows you to remotely control a machine as if you were sitting in front of it and using its keyboard and mouse. We’ll show you how to configure your Linux Mint machine as a VNC server.

WHAT IS VNC?

The acronym “VNC” stands for “Virtual Network Computing”, and allows a computer with a VNC server to transmit its keyboard, mouse, and monitor information to a remote computer. This essentially allows the remote computer to control the server computer. VNC technology was originally developed by the Oracle corporation in the 1990s, and the technology was later purchased by AT&T. A variety of different VNC implementations have been developed for every operating system, and this means a VNC client on, say, a Windows computer can control a VNC server on a Linux Mint system.

SECURITY LIMITATIONS

Note that by default, the version of VNC included with Linux Mint does not encrypt the connection, so that means anyone listening in on your network can in theory see everything you do on the remote computer. So it’s best only to use Linux Mint’s VNC implementation on a local network, and on a computer that does not have high security needs.

With those limitations in mind, let’s discuss how to set up Linux Mint as a VNC server.

VNC SERVER

To access Linux Mint’s VNC server capabilities, click on the menu and type “Desktop Sharing” into the search box. The Desktop Sharing icon will appear

Click on the icon, and Desktop Sharing, the utility that controls Linux Mint’s VNC server, will then launch.

The Desktop Sharing utility offers a variety of options to customize the security and operating of Linux Mint’s VNC server. We’ll go through these options one by one.

The first option, “Allow other users to view your desktop”, allows other users to view your desktop via  a VNC client. However, in order to actual control your desktop, you need to check the “Allow other users to control your desktop” checkbox. Allowing other users to view, but not control, your desktop is useful in situations where you want other people to view your desktop without having the ability to affect your computer. For example, if you are running a presentation off your Linux Mint computer, this would allow you to share the presentation without letting the other users control your computer.

The next three options deal with security. The first, “You must confirm each access to this machine”, means that every time someone tries to connect to your Linux Mint machine via VNC, you’ll get a little pop-up box that asks for confirmation.

This allows you to refuse or allow VNC connections to your computer.

The next option lets you set an additional password to grant access to your computer via VNC. This adds an additional layer of security to your computer, since you can grant VNC access only to users to whom you have given the VNC password. Additionally, if you decide to revoke VNC access to your machine, you can do so by the simple method of changing your VNC password.

The final option, “Automatically configure UpnP router to open and forward ports”, lets you configure the VNC server to accept connection from the Internet. Generally, it is only a good idea to do this only if you know exactly what you are doing, since it is a security risk. You will also have to configure your router to allow connections on the VNC ports.

Finally, the set of options in the “Show Notification Area Icon” category govern whether or not Linux Mint will display a notification icon when there is an active VNC connection.

You can set the icon to appear all the time in the notification area, allowing you quick access to the VNC settings, but generally the icon is most useful when it is set to appear when someone accesses your desktop.

Once you have selected the appropriate settings, you can save the settings by clicking on the Close button. The VNC server will run in the background, waiting for an incoming connection.

FORCIBLY DISCONNECTING A VNC USER

If a VNC client is connecting to your desktop and you want to forcibly disconnect it, click on the VNC icon in the notification area, and then select the Disconnect option.

When you do, you’ll see a dialog box asking if you want to disconnect the remote user.

Click the Disconnect button, and the user will be disconnected.

-JM

ADDITIONAL READING:

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide

The Linux Command Line Beginner’s Guide

Find The Default Gateway In Linux Mint 15

MintRoute

It’s not immediately obvious how to find the default gateway on a Linux Mint 15 system  – you can find it in the System Settings utility, but you have to dig down several clicks. Fortunately, you can find it easily with a Terminal command.

To find the gateway, go to the Dash, search for “terminal”, and click on the Terminal icon when it appears. Once the Terminal launches, type this command:

route -n

The command will display your system’s routing table, and the default gateway will be listed in the Gateway column.

-JM

Linux Mint 15: Find An IP Address

Mintifconfing

It’s actually a lot easier to find your IP address from the command line than from the GUI in Linux Mint 15. Simply type this command at the prompt:

ifconfig

The ifconfig command will generate an output with a great deal of information.

Fortunately, most of it is useful. The “eth0″ refers to the first Ethernet connection on your system. The “indet addr” displays your system’s IP address, while “Mask” shows the subnet mask. “HWaddr” shows your Ethernet adapter’s MAC (Media Access Control) address, which is (theoretically) unique to each adapter. (Some wireless networks require you to supply your MAC address before allowing your system to connect.)

You can pipe the output from the ifconfig command to grep to quickly find the specific item you want. Let’s say you just want to find the IP address:

ifconfig | grep inet 

This time, the output will limit itself to just the IP address.

-JM

ADDITIONAL READING:

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide