Archive for the 'SSH' Category

Page 2 of 2

Hide your Shell commands

Today  I came across a neat, but pointless shell command. By running the following in shell, it will hide any commands you run.

root@server2 [/]# stty -echo

In order to disable this mode, simply remove the “-” before echo.

root@server2 [/]# stty echo

I guess there really is no point to the command, though you could always mess with your coworkers if they leave their shell prompt open :)

Enable PHP5 when PHP4 is default

The following tutorial will show how to enable PHP5 on your site, when Apache has PHP4 as default. I normally do everything through SSH, so here are the steps.

root@thelinuxnoob.com [/]# cd home/thelinux/public_html/
root@thelinuxnoob.com [~/public_html]# nano .htaccess
Add the following line to the .htaccess: AddType application/x-httpd-php5 .php
ctrl + x
ctrl + y
enter
root@thelinuxnoob.com [~/public_html]# cat .htaccess | grep php5
AddType application/x-httpd-php5 .php
root@thelinuxnoob.com [~/public_html]# chmod 644 .htaccess
root@thelinuxnoob.com [~/public_html]# chown thelinux.thelinux .htaccess
root@thelinuxnoob.com [~/public_html]#

Via FTP

Open favorite text editor
AddType application/x-httpd-php5 .php
Save as “.htaccess”
Upload through FTP client

That’s my quick tutorial of the day, tune in next time for more tutorials :)

Chattr FTW!

I’m tired of clients breaking their sites and then complaining about it saying it’s an issue with the server, when in reality it’s 100% their fault to begin with. I’ve ran into a few issues where clients needed something set in their php.ini or .htaccess in order for their site to work, such as “allow_url_fopen” or “register_globals”. So to make things easier on the client I would set these variables for them and get their site working. Normally I would not hear back from the client if they left things alone, but it seems like lately the inexperienced clients have been getting the urge to modify the changes I’ve made, thus breaking their site an either getting either a 500 or some other kind of error. To prevent something like this from happening, you can go in an change the file attributes to keep them from screwing things up by using chattr. Chattr is also useful for important files on the server, as it can prevent people from removing those critical files from the server.

The letters select the new attributes for the files: append only (a), compressed (c), no dump (d), immutable  (i),  data journalling  (j),  secure deletion (s), no tail-merging (t), undeletable (u), no atime updates (A), synchronous directory updates (D), synchronous updates (S), and top of directory hierarchy (T).

Using chattr is pretty straight forward as the syntax is not too complicated. The command below would add the A and I attributes to the file, thus making it read-only so that it cannot be deleted nor modified

chattr +ai /home/clay/public_html/.htaccess

To remove the file attributes you would simply replace the “+” with “-” like so.

chattr -ai /home/clay/public_html/.htaccess

There are other attributes that can used with chattr but “AI” are the ones I commonly use. Now you can have fun using chattr to prevent clients from changing files they shouldn’t be changing.