Archive | March, 2011

Tags:

Install ProFTPd on Ubuntu

Posted on 27 March 2011 by Chris

To install ProFTPd on Ubuntu, you will simply need to run these commands. You can run them all as is if you are logged in as root, but will need to add sudo to the beginning of each command if you are a regular user.

apt-get update
apt-get proftpd

Then just type y at the questions that come up. When it asks you if you would like to run it from inetd or standalone, it is your choice depending on your needs, but I choose standalone.

Once that is finished, you can then edit the ProFTPd configuration file. You can find that at /etc/proftpd.conf. You should not need to change anything in this file for it to work, but feel free to take a look at it to see if there is anything you want to change.

Once you are done with that, you can check to make sure that it is running by typing this.

service proftpd status

If it says that it is running, you are ready to connect! If it says that it is stopped, you can start it by running:

service proftpd start

You can then connect using any FTP client by using the ip address as the host, 21 as the port, your username for when you log into the server and it’s password. Keep in mind that by default, each user will be jailed to their own home folder. You also cannot connect to FTP as root, only SFTP.

Comments (0)

Create and Remove Directories

Posted on 25 March 2011 by Chris

To create a directory in Linux, you will use the mkdir command with the name of the directory that your want to create.

mkdir foldername

To delete an empty directory, you can use the rmdir command with the path to the folder that you want to remove.

rmdir foldername

If the folder is not empty though, it will give you an error if you use the rmdir command. Instead, you will have to use the rm command to delete the folder and everything in it. So if you are totally sure you do not need anything in the folder, you can use this:

rm -rfv foldername

That command will remove everything in the folder, outputting what it’s doing as it’s doing it.

Comments (0)

Using the du command

Posted on 17 March 2011 by Chris

Using the du command will give you a list of the directories that are in your current directory, as well as the total size of all of the files and subdirectories included in that directory. I personally prefer to use the following, which will show the sizes in an easier to read format. It will show the files in GB or MB as well as KB, instead of all KB, which is what you will get with just du alone.

du -h

To show the size of a particular directory, you can specify that at the end of the command. It will output the size of the directories and subdirectories that are in that folder. The following will show the directories and subdirectories in the public_html folder and all of it’s subdirectories, in human readable format. The last value will be the total size.

du -h /home/user/public_html

You can also list the files as well as the directories by adding the -a flag. This will make it list all files and directories in the current directory and subdirectories, as well as their sizes in human readable format.

du -ah

If you are not concerned with the individual file sizes and only the total size of the directory as a whole, you are able to use the -s flag to get a total size. I add the h flag in as well to make it easier to read

du -sh

Lastly, the way that I use du the most personally is by adding on a –max-depth value. This will specify the number or directories deep to go. So, using a value of 1 will only show the sizes of the directories that are in the current directory without going further into them. Using a value of 2 will show the directories that are in the current directory and the ones inside that.

du -h –max-depth=1

There are many, many more ways to use the du command, but these are the ones that I find myself using the most. How do you use the du command? Leave us a comment and share your knowledge as well!

Comments (1)

Tags: ,

Setting the Path

Posted on 13 March 2011 by Chris

The $PATH variable in Linux is a set of directories that it will look in for executable files when you run a command. To see what is currently in your path, you can run the following command:

root@server [~]#echo $PATH

Which should give some output like this:

/usr/local/bin:/bin:/usr/bin:/home/username/bin

If there was a directory that you wanted to be able to run commands out of without using the full path to the directories, you want to add them to your $PATH. To do that, you will want to edit the .bash_profile, which will be found in /home/user if you need to add it for a user that you created or /root if you are wanting to add it to the path for root. So open that file with your favorite text edit editor and add something like this. In this example, we will be adding the path /home/bin.

root@server[~]#nano /root/.bash_profile

Then under the section that says “User specific environment and startup programs”, you would add the following:

export PATH=$PATH:/root/bin

Then save the file. Now you can make sure that it was added correctly by using echo $PATH again.

root@server [~]#echo $PATH

Which should output the same thing but with the newly added path as well.

/usr/local/bin:/bin:/usr/bin:/home/username/bin:/root/bin

Once you do that, you are able to run any executable files that are in that folder without using the full path. For example, if you have test.sh at /root/bin/test.sh, you can just type in test.sh anywhere in the file system and it will run, you will no longer need to type in /root/bin/test.sh.

Comments (3)

Quick Tip: Directory index forbidden by Options directive

Posted on 09 March 2011 by Chris

Getting Directory index forbidden by Options directive when trying to list files using the .htaccess?  Check to make sure that you DON’T see this in your httpd.conf or welcome.conf file.

 


Options -Indexes

 

The httpd.conf file will be at /usr/local/apachel/conf/httpd.conf on a server with cPanel and at /etc/httpd/conf/httpd.conf on a base CentOS install.  The welcome.conf should be at /etc/httpd/conf.d/welcome.conf and my not exist at all on a cPanel server.

 

I like to check for those lines in the files using these commands.

 

grep -i indexes /etc/httpd/conf/httpd.conf ; grep -i indexes /etc/httpd/conf.d/welcome.conf

 

Make sure that everything is set to +Indexes in those files and add this in the .htaccess of the folder you would like to have a list of files in!

Options +Indexes

Comments (0)

Tags: , , ,

Install ProFTP on CentOS

Posted on 07 March 2011 by Chris

To install ProFtp on CentOS, the first thing that you will want to do is to make sure that vsFTP is not already installed on your server.

root@server[~]#yum remove vsftpd

Then, you will want to go into the /usr/src directory and download the latest version of ProFTP to that folder.

root@server [~]#cd /usr/src
root@server [/usr/src]# wget ftp://proftpd.mirrors.tds.net/pub/ProFTPD/distrib/source/proftpd-1.3.4rc1.tar.gz
–2011-03-07 03:25:48– ftp://proftpd.mirrors.tds.net/pub/ProFTPD/distrib/source/proftpd-1.3.4rc1.tar.gz
=> `proftpd-1.3.4rc1.tar.gz’
Resolving proftpd.mirrors.tds.net… 216.165.129.134
Connecting to proftpd.mirrors.tds.net|216.165.129.134|:21… connected.
Logging in as anonymous … Logged in!
==> SYST … done. ==> PWD … done.
==> TYPE I … done. ==> CWD /pub/ProFTPD/distrib/source … done.
==> SIZE proftpd-1.3.4rc1.tar.gz … 59791418
==> PASV … done. ==> RETR proftpd-1.3.4rc1.tar.gz … done.
Length: 59791418 (57M)

100%[===========================================================================================================================================================>] 59,791,418 1019K/s in 34s

2011-03-07 03:26:24 (1.66 MB/s) – `proftpd-1.3.4rc1.tar.gz’ saved [59791418]

Then, you will want to decompress the file.

root@server[/usr/src]#tar -xzvf proftpd-1.3.4rc1.tar.gz

That should create a folder in the /usr/src named proftpd-1.3.4rc1. Go into that folder and we can configure and install it all with one line.

root@server[/usr/src]#cd proftpd-1.3.4rc1
root@server[/usr/src/proftpd-1.3.4rc1]#./configure && make && make install

And go back a folder and delete the proftp folder and the tar file. We won’t need those again.
root@server[/usr/src/proftpd-1.3.4rc1]#cd ..
root@server[/usr/src]#rm -rfv proftpd-1.3.4rc1 proftpd-1.3.4rc1.tar.gz

Once that is done, we will need to symlink the proftp binary to the /usr/sbin folder.

root@server[/usr/src]#ln -s /usr/local/sbin/proftpd /usr/sbin/proftpd

Once that is done, we will create the script in /etc/init.d to allow it to start at boot time.

root@server[/usr/src]#nano /etc/init.d/proftpd

And paste this into that file:

#!/bin/sh
# $Id: proftpd.init,v 1.1 2004/02/26 17:54:30 thias Exp $
#
# proftpd This shell script takes care of starting and stopping
# proftpd.
#
# chkconfig: – 80 30
# description: ProFTPD is an enhanced FTP server with a focus towards \
# simplicity, security, and ease of configuration. \
# It features a very Apache-like configuration syntax, \
# and a highly customizable server infrastructure, \
# including support for multiple ‘virtual’ FTP servers, \
# anonymous FTP, and permission-based directory visibility.
# processname: proftpd
# config: /etc/proftp.conf
# pidfile: /var/run/proftpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x /usr/sbin/proftpd ] || exit 0

RETVAL=0

prog=”proftpd”

start() {
echo -n $”Starting $prog: ”
daemon proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
}

stop() {
echo -n $”Shutting down $prog: ”
killproc proftpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
}

# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
status)
status proftpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/proftpd ]; then
stop
start
fi
;;
reload)
echo -n $”Re-reading $prog configuration: ”
killproc proftpd -HUP
RETVAL=$?
echo
;;
*)
echo “Usage: $prog {start|stop|restart|reload|condrestart|status}”
exit 1
esac

exit $RETVAL

Then save the file and exit. We will want to make that executable as well.

root@server [/usr/src]#chmod 755 /etc/init.d/proftpd

After that you will need to edit line 30 in /usr/local/etc/proftpd.conf and change the group to nobody.

root@server [/usr/src]#nano -w +30 /usr/local/etc/proftpd.conf

Then change that group line to say nobody. User should already say nobody when you open that file.

# Set the user and group under which the server will run.
User nobody
Group nobody

Also, if you would like your FTP users to be able to change the permissions of their files, you will want to comment out lines 39-42. So it should go from this:
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>

to

# Bar use of SITE CHMOD by default
#<Limit SITE_CHMOD>
#  DenyAll
#</Limit>

Once that is done, all that we need to do is tell it to start on boot and start the ftp server. So, first you will run this.

root@server [/usr/src]#chkconfig –levels 235 proftpd on

Then finally, start the ftp server.

root@server [/usr/src]#/etc/init.d/proftpd start
Starting proftpd: [ OK ]

If you see the OK there, it should be started and ready to connect. Also to check on the status of the ftp server, you can run the following:

root@server [/usr/src]#service proftpd status
proftpd (pid 15853) is running…

Also, once it is in the /etc/init.d folder, you are able to start, stop and restart the FTP server with the service command, such as
service proftpd stop
service proftpd start
service proftpd restart
service proftpd status

Comments (0)

Tags:

Extract a tar and a tar.gz file

Posted on 07 March 2011 by Chris

To extract a tar file named file.tar, you can use the following command.

root@server [~]#tar -xvf file.tar

In that, the x is the part that extracts, f defines the file and v gives verbose output, telling you what is being extracted.

To extract a file that is named file.tar.gz, you will use the z flag to ungzip it as well.

root@server [~]#tar -xzvf file.tar.gz

Comments (2)

Tags:

Show Grants for a MySQL User

Posted on 06 March 2011 by Chris

To show the granted permissions for a MySQL username, first you will need to know the username that you need to check on. In this article, the username will be test_db. So, to show the information for the user, you will first drop into the mysql shell.

root@server [/]#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 0001
Server version: 5.0.91-community MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

Then, you use the show grants command to show the granted permissions for that MySQL user.

mysql> show grants for ‘test_db’@'localhost’;
+————————————————————————————————————————————————————————————————–+
| Grants for test_db@localhost |
+————————————————————————————————————————————————————————————————–+
| GRANT USAGE ON *.* TO ‘test_db’@'localhost’ IDENTIFIED BY PASSWORD ‘*DYC75DW0KD63D82OEGMCF334LKSUTAQQLUDRW’ |

| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE ROUTINE ON `test\_db`.* TO ‘test_db’@'localhost’ |
+————————————————————————————————————————————————————————————————–+
2 rows in set (0.00 sec)

You can tell the database that it it granted the permissions to from this part of that statement, where test\_db is the database test_db.

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE ROUTINE ON `test\_db`.* TO ‘test_db’@'localhost’ |

Comments (0)





Download v1 of the RandomLinux.com Android app! Stay up to date on everything that's Linux right from your phone or tablet! Download below!