Linux Command Reference Sheet for Webmasters

This is a quick reference for the most used linux commands by me. I will update this as more command become important. For now this is most web developers need.

This will list all the files in the current directory.

ls
ls /path/to/directory/to/list

This will allow you to change directory.

cd /path/to/directory
cd ..                  Go back 1 directory 
cd ~                   Will take you to your home directory

This will allow you to change users. You will have to enter the user’s password if you are not the root. (Super user)

su username       Change to the user username
su -              Change to the user root

This will allow you to change the password of the current user.

passwd
passwd username   You must be root to specify username

To create a directory.

mkdir dirName            This will create the dir in current directory
mkdir /path/to/directory

To delete a directory.

rmdir dirName            This will create the dir in current directory
rmdir /path/to/directory

To create or edit a file using vi.

vi /path/to/file

To change the permissions of the file or folder.

chmod [permissions] [path/to/file/folder]
chmod 0777 /home/test

To change the owner of the file or folder.

chown [owner] [path/to/file/folder]
chown silvio /home/test

To change the group of the file or folder.

chgrp [group] [path/to/file/folder]
chgrp apache /home/test

Importing a Subversion SVN dumped file

You must create the repository folder first, if you do not know how please follow this guide: Adding new repositories for subversion

Step 1: Switch to user root

su -

Step 2: Import your dump into your repository. cat sends the contents of the file into the screen, then the pipe allows us to run another command which tells it to send the data to the svnadmin load command instead.

cat /path/to/file | svnadmin load /path/to/svn/FolderName

All done!

Adding New Repositories for Subversion

This will tell you step by step how to create new repositories for many linux based operating systems, like Fedora and CentOS

This post assumes you already have subversion installed and configured on your server. If you do not I will eventually have a post explaining how to install and configure it.

Step 1: Switch to user root

su -

Step 2: Create a new folder with all your other repositories.

mkdir /path/to/svn/folderName

Step 3: Make this into a version control directory

svnadmin create /path/to/svn/folderName

Step 4: Set the Group and owner of the folder and all files recursively

chown -R apache.apache /path/to/svn/folderName

Step 5: Set the permissions on the files giving access to the owner and group ; read, write, and execute, and everyone else just read and execute

chmod -R 0775 /path/to/svn/folderName

Step 6: Enable web content outside of normal apache directory

chcon -R -t httpd_sys_content_t /path/to/svn/folderName

Step 7: Enable commits over http

chcon -R -t httpd_sys_rw_content_t /path/to/svn/folderName

Step 8: Restart apache

This works on most linux based operating systems

service httpd restart

if not use this:

/bin/systemctl restart httpd.service

This new repository should be ready to go!

If you want to import a pre-dumped file then view this post: Importing a Subversion SVN dumped file