You are on page 1of 1

cd Change directory.

This command allows you to move around to different


directories on the server simply by typing cd and then the desired directory that
exists. Example: cd /home
pwd Shows you an output of your current location on the server in shell
ls lists non hidden files in the current directory you are in on the server.
ls -al Lists all files in current directory showing permissions, user, group,
date modified, hidden files, etc.
touch will create a new text file. When using this command you will need to include
the text file name and extension such as .txt, .php, .html etc. Also please note
this command will create the file in the current directory you are in unless
specified a location.
rm rm will remove a file specified in the command. For example: rm
newtextfile.html. When doing this command it will prompt you if you are sure you
want to delete that file. RM also has various options you can use. Some options
are: -f (force), -r (recursive), -d (directories), -i and -I do different things.
-i will prompt before removal and -I will prompt before removing more than 3 files.
mkdir This will create a new directory in the location you are currently at in
shell.
rmdir Remove a directory. It must be empty in order to run this. However you can
run the following to remove an entire directory with all content inside: rmdir -rf
directory name
mv MV will allow you to move a file to another location on the server. This
command will also allow you to rename the file when moving it to another location.
Example: mv /home/newfile.txt /root/newfile_renamed.txt
cp cp will copy files to another location on the server specified in the
command. You can also copy directories recurrsevily as well by doing the following:
cp -ar /starting/example/location /destination/location
chmod Will modify perfmissions to a file/directory. Example: chmod ###
/location/of/file.html; chmod ### /location/of/directory will change the
permissions of the directory but not the files in that directory. To change
recursively you will want to do the following: chmod -R ### /directory.
chown Changes the owner and group of a file. As with anything else with Linux, most
commands have varying options for their usage. For example: chown -R user:group
/public_html/; The -R will recursively change ownership of all files and folders
with in the listed directory.
man man will open up a manual with in shell and provide you further explanation
on the command you are trying to run. For instance if we want to know more about
rm, we can run man rm and a manual will open.
cat display contents of a file. Example: cat filename.txt
tail displays the last 10 lines of a file. You can display more than 10 lines if
desired by running: tail -n # filename
Text editor options vi, vim, nano all will allow you to edit text files. Each
have their own commands to operate with in them. To learn more about each check out
their man pages.
apt-get apt-get depending on the options allow you to look for, install,
upgrade, etc packages on to your server through shell.
grep command used to search files for the occurrence of a string of characters
that matches a specified pattern. For simple example: grep root /etc/passwd; this
will provide us any lines with in passwd that contain root. Grep is also a very
powerful tool that has many options to increase searching capabilities with in a
file and simplify the output.
find searches the directory tree rooted at each given starting-point by evaluating
the given expression from left to right, according to the rules of precedence until
the outcome is known. If no starting point is is specified . is assumed as the
starting point. Find can also be a very powerful tool used together with other
commands such as grep. Example: find . name *.php | grep i config

You might also like