ubuntu tips

Ubuntu tips and tricks

FTP

sudo apt-get install vsftpd
sudo nano /etc/vsftpd.conf
Change the following lines;
Uncomment the line;#write_enable=Yes
Uncomment the line; #local_umask=022
Save and exit
Restart the ftp server;
sudo service vsftpd restart
vsftp monitor;  http://ubuntuforums.org/showthread.php?t=875070


Install curl, php5-gd, php_cli and phpmyadmin;
sudo apt-get install curl php5-curl php5-gd php5-cli phpmyadmin


networking stuff

To put a fixed IP address, cut paste the following; sudo nano /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.230
gateway 192.168.1.1
netmask 255.255.255.0

12.04 and latter take the DNS entries out of /etc/resolv and put it in the interfaces file.
dns-nameservers 8.8.8.8

You might like to make sure that it can never change by doing the following;
sudo apt-get remove dhcp-client
To put in a fixed DNS server;
sudo nano /etc/resolv.conf
nameserver 8.8.8.8

Lets say you put another network card in, say to replace the one on the mother board which is stuffed. But you decide to do this AFTER you have already loaded the system… and you even remember to turn the one off in the BIOS, but Ununtu will bring the new one up as eth1. Not exactly what you had in mind….. To ‘remove’ eth0 and replace it with eth1;

sudo nano /etc/udev/rules.d/70-persitent-net.rules

# PCI device 0x1022:0x2000 (pcnet32) SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”0d:0a:12:ac:d2:a4″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″

# PCI device 0x1022:0x2000 (pcnet32) SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”0a:1d:35:21:a7:00″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth1″

comment out the first line with a ‘#’ at the front and on the second line eth1 line to eth0:
You could then probably do a network up/down, but was in a hurry and just rebooted.

Nice trick to get your WWW address into dropbox
gedit send_ip.sh &
copy in “cat <(date) <(curl icanhazip.com)> /home/me/Dropbox/current_ip.txt” without the quotes
save, close.
chmod +x send_ip.sh

crontab -e

*/5 * * * * /bin/bash cat <(date) <(curl icanhazip.com)> /path_to_it/send_ip.sh

[(all one line), close & save]

Now the current_ip.txt is updated by cron every 5 minutes


Swappiness

What is swappiness and how do I change it?

The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory.

swappiness can have a value of between 0 and 100 swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache

The default setting in Ubuntu is swappiness=60. Reducing the default value of swappiness will probably improve overall performance for a typical Ubuntu desktop installation. A value of swappiness=10 is recommended, but feel free to experiment. Note: Ubuntu server installations have different performance requirements to desktop systems, and the default value of 60 is likely more suitable.

To check the swappiness value

cat /proc/sys/vm/swappiness
To change the swappiness value A temporary change (lost on reboot) with a swappiness value of 10 can be made with;
sudo sysctl vm.swappiness=10
To make a change permanent, edit the configuration file with your favorite editor:
gksudo gedit /etc/sysctl.conf
Search for vm.swappiness and change its value as desired. If vm.swappiness does not exist, add it to the end of the file like so:
vm.swappiness=10
Save the file and reboot.  https://help.ubuntu.com/community/SwapFaq


Screen blanking control from command line

August 2011 was the start of my ‘lets see how long I can run a system from the command line’ personal challenge.
I installed Ubuntu 10.04 on a PC at work with no windows manager, just command line FTW!
First thing that bothered me is that the terminal would go into power save every few minutes. How to turn that off? This guy to the rescue;  http://www.cyberciti.biz/tips/linux-disable-screen-blanking-screen-going-blank.html
setterm -powersave off -blank 0
Resets the terminal to its power on state:
setterm -reset
Alternatively, initialize terminal:
setterm -initialize
NOTE, you cant do any of this from SSH, you have to be at the local terminal. (Other wise you get a “cannot (un)set powersave mode” message back.


backing up

 http://www.psychocats.net/ubuntu/remastersys looks to be an interesting way to make an .iso of your current system.
 http://www.psychocats.net/ubuntu/backup has a few suggestions that need looking at.

 http://www.ahsay.com/jsp/en/home/index.jsp?rf=www.google.com&kw=ahsay is what Gary uses, its supposed to have a free for home use version, but a bit of look reveals a fair bit of confusion. Im interested in sticking with this one as it is supposed to do live mySQL backups which is what I need for the photo gallery.

 http://clonezilla.org/ will make a clone of an unmounted file system. Nice, but I don’t want to have to keep taking my site off line every few days to back it up.


bench testing

Found it a bit hard to find good apps to bench test a system from the command line.

time echo “scale=5000; 4*a(1)” | bc -l -q will calculate pi to a bunch of places and report the time it took.
sudo apt-get install hardinfo then hardinfo -r -f html > /var/www/report.html YMMV, crashed more than it worked.


Server tweaks

 http://www.howtogeek.com/wiki/Tweaking_a_Dedicated_Virtual_Web_Server


Screen brightness on old Macbook

Installed Ubuntu 14.04 on an old Macbook. Everything worked, but the screen brightness did not change when I hit the keys (the system showed the logo changing, but nothing happen). To get the screen brightness keys working with your Nvidia graphics card, create a file in the xorg.conf.d directory, e.g:

sudo gedit /usr/share/X11/xorg.conf.d/10-nvidia-brightness.conf
Paste the following into the file:

Section “Device”
Identifier “Device0”
Driver “nvidia”
Option “RegistryDwords” “EnableBrightnessControl=1”
EndSection
Log out and log back in, or reboot, and the brightness keys now work!

Leave a comment