Posts Tagged ‘linux’

Installing PNG support for Debian

Saturday, May 26th, 2012 | Life, Tech

Following on from my recent post about adding JPEG support, I also needed to add PNG support. I couldn’t get the RPM’s to work, so I had to do this manually as well.

wget http://downloads.sourceforge.net/project/libpng/00-libpng-stable/1.2.39/libpng-1.2.39.tar.gz?use_mirror=kent
tar -zxvf libpng-1.2.39
cd libpng-1.2.39/scripts
cp makefile.linux ../makefile
cd ../
make
make install

Changing your timezone in Debian

Tuesday, May 15th, 2012 | Life, Tech

If you want to change your timezone on Debian, use the following command.

dpkg-reconfigure tzdata

Changing your SSH port

Thursday, May 3rd, 2012 | Life, Tech

If you want to change your SSH port to something a little less obvious, it’s easy to do. It’s debatable how much security it actually gives you, but it will certainly make you feel safer, and that is probably the most important thing.

pico /etc/ssh/sshd_config

I’m using pico in this example, but vim will work just as well. You should find a line which is commented out, specifying that the port is 22. This doesn’t need to be uncommented normally, as it defaults to port 22.

#Port 22

Just uncomment this and put a new port number in.

Port 8473

Now save the file and exit. Finally, restart SSH for it to take affect.

/etc/rc.d/init.d/sshd restart

Don’t forget, next time you SSH in you will need to use the new port number!

ssh -p 8473 hostname

Using locate to search for files from the terminal

Sunday, April 15th, 2012 | Life, Tech

Need to locate a specific file somewhere on your system? Luckily, there is an appropriated named search tool which you can use to do that. It’s called locate and it’s very similar to file search in Windows file manager.

Not all Linux installs come with locate, so you may need to install it.

yum install locate

Also, the first time you run it, it will need to build the database, so that will take a little longer. But once it is up and running, it is pretty fast. Simply use the command followed by a file name, or even just part of a file name, to get a list of all the files on your system that match.

locate httpd.conf

View disk space usage by directory in Linux

Wednesday, March 21st, 2012 | Life, Tech

If you need to get a break down of how much space each directory is using, you can do that using the du command. Using a few choice options it will produce a list of all directories in the current folders and how big they are.

du -sch

Faster grepping with fgrep

Thursday, March 15th, 2012 | Life, Tech

If you use the Unix terminal, you’re probably familiar with grep. It’s a great search tool. But sometimes it is a little slow. Luckily, there is a faster version, with the original name of fgrep, though you might be surprised to learn it doesn’t actually stand for fast grep. But don’t be confused – it is faster.

You use it in avery similar way to the way you would use grep. So for most occasions, simply replace grep with fgrep for faster results.

Following files using tail

Saturday, March 3rd, 2012 | Life, Tech

Tail is a useful command which allows you to see the end of a file. This is probably most commonly used when you want to look at log files as the entries of most interest are usually at the bottom. For example, if you wanted to view the last 50 lines of a log file you could use the following command.

tail -n 50 filename.log

A cool feature of tail is that you can also follow a file – that means continually monitoring it as changes come in. So if you are looking at the Apache error log for example, you could begin tailing the log and then cause an error and you will see it instantly come through on the log.

tail -f error_log

View all PHP scripts currently running

Friday, February 24th, 2012 | Life, Tech

Need to get a list of all the PHP scripts currently running? Actually, this technique works for everything, you just need to change the argument you pass to grep, but for the purpose of this example, I’m going to say we’re looking for PHP scripts.

ps aux | grep php

This will then produce a list of all the scripts. The ps aux command gives us a list of every processing running on the system. We then pass this through to grep and search for what we want – in this case processing which contain “php”.

Saving files in memory

Thursday, February 16th, 2012 | Life, Tech

If you need super quick access to a file, for example a log file which isn’t going to be too big but it being used by a script which is time critical, then rather than writing it to disk, you can mount part of your file system in memory and write to it there.

This has the disadvantage that when you restart your system, you will lose the data. But for test scripts, logs or other temporary files that you don’t mind getting lost, it can really speed up performance.

Luckily, most systems come with a an area mounted in memory already – so you don’t even need to configure it!

cd /dev/shm

If said directory exists, you’ll have a memory mounted directory already and can start using it immediately.

Get the system time from the terminal

Monday, January 30th, 2012 | Life, Tech

Wondering what your system date/time is? Easy!

date

It’s that obvious ;). Don’t mistake it with the command “time”, which won’t return you what you want.