David Slack - Web developer

Useful Linux commands

This is some of the things I keep forgetting and things I always use. Might be usefull to someone (including me)

Find the hostname:

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }hostname{/syntaxhighlighter}

Change driectory:
cd

{syntaxhighlighter brush: xml;fontsize: 100; first-line: 1; }{/syntaxhighlighter}

E.g. To change to the root directory use

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }cd /{/syntaxhighlighter}

Rename a file:

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }rn FILENAME NEW_FILENAME{/syntaxhighlighter}

Find the version of the Linux OS (mine is CentOS 5.5)

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }cat /etc/*release*{/syntaxhighlighter}

If you are told you have an email by the system e.g. You have mail in /var/spool/mail/root then use 'cat' to read it. So for the above you could try

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }cat /var/spool/mail/root{/syntaxhighlighter}

Check the files/folders in a folder
ls

To create a tarball from the folder httpdocs make sure your in the right folder so use 'ls' then if you see the folder type

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }tar -zcf httpdocs.tar.gz httpdocs{/syntaxhighlighter}

To copy a folder and all files use cp -R <SOURCE> <DESTINATION> like:

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }cp -R /home/foo/public_html/ /home/bar/public_html/{/syntaxhighlighter}

To delete a folder and all the files in it use rm, so to delete the folder 'foo' from the folder we are in use

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }rm -rf foo{/syntaxhighlighter}

To change all the files in a folder to the same permission we use chmod recursive like chmod -R xxxx /path/to/top/directory so to get all the files in the file folder we could use

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }chmod -R 0777 files{/syntaxhighlighter}

To update php to the newest version of 5.2 you must exclude all 5.3 versions like:

{syntaxhighlighter brush: as3;fontsize: 100; first-line: 1; }yum update PHP --exclude=php*5.3*{/syntaxhighlighter}

Latest content

There are lots of developers out there with varying degrees of experience and expertise, some mid level, some junior and some senior. Some...
First thoughts are Symfony is ace!Only been using Symfony for 1 project but the amount of coding it has saved has been worth the time spent...
The Lost and Found website was built by myself (David Slack) and designed by Arm & Eye.The site was created to promote a bar and...

Social networks

Contact me here or catch me on one of
the social networks below


What I'm listening to

Off-site News

My blog

Wednesday, 2 August, 2017 - 06:56
There are lots of developers out there with varying degrees of experience and expertise, some mid level, some junior and some senior. Some developers...
Tuesday, 5 March, 2013 - 09:49
First thoughts are Symfony is ace!Only been using Symfony for 1 project but the amount of coding it has saved has been worth the time spent learning...
Monday, 3 December, 2012 - 10:07
As a web developer and web designer I need to take into account everything on a site from SEO, marketing, usability across devices, the look and feel...

Try this on your mobile

Use your QR reader to read this

You should be able to use this right from the screen

Latest tweets

Calendar

M T W T F S S
 
 
 
 
 
 
1
 
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
 
10
 
11
 
12
 
13
 
14
 
15
 
16
 
17
 
18
 
19
 
20
 
21
 
22
 
23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
 
31
 
 
 
 
 
 

You are here

Back to top

Copyright David Slack - Web developer