Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Thursday, December 27, 2012

Updates for EOL Ubuntu releases

When release reaches it's EOL, the repositories are no longer available at old location, so we have to change their addresses like this:

Edit /etc/apt/sources.list and change 'archive.ubuntu.com' to 'old-releases.ubuntu.com'
or
We can do this with 
sudo sed -i -e 's/archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

and then update with 
sudo apt-get update && sudo apt-get dist-upgrade


Thanks to fossfreedom for providing the info on this topic.

Thursday, December 1, 2011

Firefox 8 in Ubuntu 10.10


http://news.softpedia.com/news/How-to-Install-Firefox-8-in-Ubuntu-10-04-and-10-10-232859.shtml

P.S. There is also very interesting add-on for the Firefox, that helps to solve the problems with incorrect flash player installations. It's called "Flash-aid".

Wednesday, July 6, 2011

Dual-boot Windows XP and Linux Ubuntu time problem

If you are using both Windows and Linux at your PC, then chances are that you will face a problem of time difference between operating systems. To solve this problem:
gksudo gedit /etc/default/rcS
Change UTC=yes to UTC=no

Wednesday, April 20, 2011

Recovery of lost partitions and files in Ubuntu

There is really nothing to say about it but one word: TestDisk.

Tuesday, April 19, 2011

Making a Video DVD from VIDEO_TS folder in Ubuntu

This task turned out to be easy to accomplish. Just 2 simple commands and voila.

1. mkisofs -dvd-video -o image.iso /dvd

where /dvd - the folder that contains VIDEO_TS folder.
This command will create iso file to burn to dvd disc.

2. growisofs -dvd-compat -Z /dev/scd0=image.iso

The second command burnes iso image to the dvd disc.

Tuesday, March 1, 2011

Root user and password in Ubuntu

By default, Ubuntu has a root password set as a hash. Sometimes, you can make a mistake, for example, remove your account from the group that allowed to use sudo. In a such cases, it's useful to have an access to the root user itself.
To set root password manually we should type in the shell:
sudo passwd

Monday, February 28, 2011

Using SCP to copy files between hosts

To copy remote file to your filesystem use the following syntax:
scp your_username@remotehost.edu:foobar.txt /some/local/directory

To copy local file to remote filesystem use the following syntax:
scp foobar.txt your_username@remotehost.edu:/some/remote/directory

To copy folder to a remote filesystem use
scp -r foo your_username@remotehost.edu:/some/remote/directory/bar

Friday, January 21, 2011

Cloning Virtual Machine from snapshot in virtualbox

Today I've faced an interesting task to make a new virtual machine from a snapshot of existing one in virtual box. After a little research, I've found nice guide how to do it:

To clonehd the Current State of a disk:
  • Open the Virtual Media Manager (Menu: File>Virtual Media Manager).
  • Navigate to the hard disk you want to clone and fully expand the tree (use * key on numeric keypad).
  • Find the {hexUUID}.vdi file that is attached to the VM you want to clone the Current State of.
  • Click the filename to the right of the 'Location:' displayed at the bottom of the window.
  • Ctrl+C / Copy to copy the text to the clipboard, which will be something like:
    (path){b6441469-5ccb-418c-8fdd-73c5e1a17314}.vdi
  • Ctrl+V / Paste and extract the hexUUID value (removing the {} brackets) and run clonehd to clone it!
    C:> VBoxManage clonehd b6441469-5ccb-418c-8fdd-73c5e1a17314 CloneDisk.vdi


To clonehd a snapshot of a disk:
  • Open the Virtual Media Manager (Menu: File>Virtual Media Manager).
  • Navigate to the hard disk you want to clone and fully expand the tree (use * key on numeric keypad).
  • Find the {hexUUID}.vdi file that is attached to the VM (and Snapshot) you want to clone.
  • Click the filename to the right of the 'Location:' displayed at the bottom of the window.
  • Ctrl+C / Copy to copy the text to the clipboard, which will be something like:
    (path){75bd6ab1-ce25-4b56-aa39-7826c9ebcc93}.vdi
  • Ctrl+V / Paste and extract the hexUUID value (removing the {} brackets) and run clonehd to clone it!
    C:> VBoxManage clonehd 75bd6ab1-ce25-4b56-aa39-7826c9ebcc93 CloneDisk.vdi


There is no GUI at the moment, but it could be easily done in command line.

Swap in Ubuntu

Swap can a dedicated partition or just a file on your hard disk, mounted as a swap partition. I don't think, that anyone could have a problem marking partition as a swap, but creating swap as a file could be more interesting task to do.
Here is quotations from official Ubuntu documentation:
"
For Adding a 512 MB swap
  • Creating a file for 512 MB size you want:
We will create a /mnt/512Mb.swap swap file.
sudo dd if=/dev/zero of=/mnt/512Mb.swap bs=1M count=512

Here count=512, means we want our file to contain 512 blocks of bs=1M, which means block size = 1 mebibyte (1 048 576 bytes). Be careful *not* to do this dd of=/mnt/512Mb.swap bs=1M seek=512 count=0 Though the file grows to 512Mb immediately, it will have holes that makes it unusable.
  • Formatting that file to create a swapping device:
sudo mkswap /mnt/512Mb.swap

  • Adding the swap to the running system:
sudo swapon /mnt/512Mb.swap

The additional swap is now available and can be seen by "cat /proc/meminfo"
  • Making the change permanent:
Edit the /etc/fstab: 
gksudo gedit /etc/fstab

Add this line at the end of the file:
/mnt/512Mb.swap  none  swap  sw  0 0
Save. After the next reboot the swap will be used automatically.
Here we go! 

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.

We can check swap with the following commands:
  • sudo fdisk -l
  • cat /proc/swaps

Tuesday, March 16, 2010

Making permanent mounts in Ubuntu 9.10

sudo gedit /etc/fstab
Add at the end of the file:
/dev/sda7 /media/work ext4 rw,user,auto 0 0
Number "/dev/sda7" can be found with df -h or in system monitor.
"/media/work" is the name of the folder that will be associated with device.
Other options are self-explaining.

P.S. Notice, that folder "/media/work" must exist and permission have to be set to allow appropriate actions for user. Otherwise, only "root" will be able to change something on the hdd.

Sunday, March 14, 2010

Problems with clicking on Flash buttons in Ubuntu 9.10 with compiz

WORKAROUND 1: Disable compiz
WORKAROUND 2: Remove flashplugin-nonfree / flashplugin-installer and install from adobe
WORKAROUND 3: Open a terminal and enter:
gksudo gedit /usr/lib/nspluginwrapper/i386/linux/npviewer
Then add: export GDK_NATIVE_WINDOWS=1 before the last line of text.

Third workaround worked better for me.

Thursday, March 11, 2010

VNC and multi-user environment in Ubuntu 9.10

To allow multiple users connect to our Ubuntu box, we need to install VNC Server with following commands:
sudo apt-get install vnc4server
It allows to use different sessions for multiple logins, so users can be separated from each other and won't fight for mouse as well as they won't see applications of each other :-)
Then we need to assign a password to our VNC logins. It can be done through running this command:
vncpasswd
Then we can launch a test desktop by running:
vncserver :1
Number here is a display number. Local user runs display :0 etc.
Now we can connect to it, by specifying either port number (::5901) or display number (:1) in remote VNC viewer. However, after logging in, the desktop won't be as usual X session. It will be presented as simple GUI with command line or just as a blank screen with cursor in form of cross.
Now we need to shutdown the session  with:
vncserver -kill :1
Next, edit ~/.vnc/xstartup. It should look similar to:
#!/bin/sh

# Uncomment the following two lines for normal desktop:
#unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc

#[ -x /etc/vnc/xstartup ] && sh /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &

unset SESSION_MANAGER
sh /etc/X11/xinit/xinitrc

Now we can start the vncserver :1 again and connect to it. Pay attention to user, under which vncserver have been started. It means, that if we have started server under our current user, the remote login will be as the same user.
To enable different user to log in, we should create another user in Ubuntu, install SSH server and make all the steps from above. Then we can first SSH to our Ubuntu box, log in under different user (which we want to use for our remote VNC session), in console session type vncserver :[number] and then launch vnc viewer on remote client and connect to the session just created.

To secure traffic on it's way, we can tunnel it through the SSH connection. For this we need to add SSH tunnel at the Putty menu by specifying source port as "5900" (if we are connecting to display :0) and destination "localhost:5900". Then connect to the server and leave Putty screen as is. Now we just need to connect via VNC to localhost:5900 and our traffic will be tunneled to SSH connection. That's it.


Whew, sounds like a lot of routine, but I haven't found the way to automate it yet.
The good thing is that at least it's working  ;-)

P.S. To get multiple instance of Firefox (or any other Mozilla application) running simultaneously when we logged on the same user as local session, we need to set the environment variable MOZ_NO_REMOTE=1 before starting Firefox.
To do this just use:
export MOZ_NO_REMOTE=1

Firestarter - another great GUI front-end to iptables

We can use apt-get install firestarter to get firestarter running. After startup wizard, our rules will be imported to the iptables. Even if firestarter's gui isn't running, firewall is actually working so we don't have to worry about it.
We can check firewall status by running:
sudo /etc/init.d/firestarter status
By default, GUI won't be started after computer reboot.
To override this, we should make a simple configuration changes to some files.
First of all, we need to add Firestarter to System - Preferences - Startup Applications. The add an entry stating:  
sudo firestarter --start-hidden
However, the password have to be specified to run this command, because it runs with root privileges. Moreover, we can't specify the password since this is logging script, so it just won't work at all. To get it working, we should edit /etc/sudoers file with any text editor or via sudo visudo command which is preferable.Then add the following line to the end of the file or it won't work:
[username] ALL=NOPASSWD: /usr/sbin/firestarter

That's it! Now are done and can start using firewall!

P.S. It's not recommended to start GUI automatically on system startup since it's a security breach.
P.P.S. Uninstalled it  after 1 day of using. Allows only 2 network interfaces to be configured as local or outside, making other interfaces to work improperly. For example, pings won't be allowed from those unconfigured interfaces at all. Maybe more inconveniences are present, but I haven't tested it any further. Moreover, after removing the Firestarter, ufw stopped working and I had to install Firestarter back and then remove it completely with apt-get remove purge command. It didn't heal ufw, so I had to completely remove it too and then install it back. Sounds ugly, isn't it?

Wednesday, March 10, 2010

UFW - simply great firewall for Linux

UFW is a very simple and powerful firewall which allows us to configure our policies in minutes!
Moreover, it allows us to configure forwarding traffic between interfaces and even NAT!
We can check UFW status by typing sudo ufw status or even just sudo ufw to see the list of available options.
By default, all outbound traffic is permitted. UFW is stateful firewall, so it tracks connections via maintaining connection table. Returning traffic permitted to pass through the firewall only if corresponding connection is in the table. Or simply, traffic allowed to return only if connection were originated from the inside network.
To open ports in the firewall, so inbound connections can be allowed, we have to add the rules. It's simple:
sudo ufw allow port number[/tcp|udp]
or 
sudo ufw deny port number[/tcp|udp] to block open ports.
To disable logging we can execute
sudo ufw logging off

Here are steps to configure routing and NAT.

First, packet forwarding need to be enabled.
We need to modify 2 configuration files:
1.  /etc/default/ufw change DEFAULT_FORWARD_POLICY to "ACCEPT".
2.  /etc/ufw/sysctl.conf uncomment /net/ipv4/ip_forward=1
After previous steps our Linux machine will begin to forward packets between it's interfaces!
Only NAT configuration left and it pretty straightforward.
We need to add rules to the /etc/ufw/before.rules file. We need to add the following string right to the top of the file after the header comments:
# nat Table rules
*nat
:POSTROUTING ACCEPT [0:0]

# Forward traffic from eth1 through eth0.
-A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

# don't delete the 'COMMIT' line or these nat table rules won't be processed
COMMIT
To enable Port Forwarding, also add the following string before COMMIT keyword. If ports to be forwarded are different on NAT device and destination then simply add :[portNumber]
-A PREROUTING -i eth1 -p tcp --dport 3389 -j DNAT --to 192.168.139.101:[portNumber]
Of course, ip networks and interface names should be replaced with appropriate. eth0 in this example is our outside interface on which translation will be performed. 192.168.0.0/24 subnet is our internal subnet which requires translation.
Only restarting the firewall left.
sudo ufw disable && sudo ufw enable

How to check system specification in Ubuntu

sudo lshw -html >> /home/igro/Desktop/1.html

Tuesday, March 9, 2010

Ntpdate + Crontab

Crontab is used to automate repetitive tasks.
We can use command crontab -e to enter the editor mode and then add tasks we need.
crontab -l shows scheduled commands for particular user.

Ntpdate is a simple program that allows us to synchronise system time once. It's not so sophisticated as ntpd daemon that continuously synchronising system time, running in background.
It's usage is also simple: ntpdate servername

It can be really handy to combine it with crontab to synchronise system clock periodically.

Just do the following:
sudo crontab -e
@hourly /usr/sbin/ntpdate 1.it.pool.ntp.org

This crontab job should be executed as root or the date won't be synchronised.
Also, the path for the program in the crontab job should be a full path. Even so ntpdate servername command would work from terminal execution, it won't from crontab job. For crontab we have to specify the full path, e.g. /usr/sbin/ntpdate servername. That is a general rule for crontab.
To check the full path of the command, we can use which command.
For example, which ntpdate.

Crontab  example:
0 */2 * * * /home/igro/Desktop/backupGNS

Following string allows us to execute backupGNS script every two hours.

Installing Packet Tracer i386 in Linux 64-bit.

I've downloaded PacketTracer-5.2.bin and my first intention was to simply install it with: chmod +x .....bin   ./....bin However, the installation complains about inconsistent architecture. The workaround is to extract .deb package from this .bin file and then to force it to install it under 64-bit operating system.
For this to be accomplished, we need to begin the installation of .bin file and after EULA has been displayed, navigate to /tmp/selfextract.[randomNumber] and get the .deb file from this directory. Then simply force it to install without checking the architecture.
sudo dpkg -i --force-all ./PacketTracer-5.2-u.i386.deb

Enjoy!

Monday, March 8, 2010

How to mount and why do we need it

Sometimes, it would be useful for us to add a path to a script that contains spaces.
Something like: "/home/igro/Ubuntu One".
For example tar can't accept path like this one.
As a workaround we can mount this path as a different folder on disk and use it as in a path script as a path.

For example:
mount -B "/igro/home/Ubuntu One" "/NewFolderName"
And after that:
tar /NewFolderName <- this is not an actual command, but the idea is about the path used.
Don't forget, that we need to create the destination folder prior to use it in mount command.

Executing .bin files

.bin files are similar to installation files in Windows.
1. First we should add an execution permission with chmod +x /[path]/[filename]
2. Navigate to file's folder.
3. Execute the file ./[filename]

Wednesday, March 3, 2010

Syslog in Ubuntu

To be able to accept remote syslog message, I installed sysklog ( k in the middle isn't a typo) and changed /etc/defaults/syslog. I added -r options so syslog accepts not only local, but also remote logs.
Then just restart the syslog daemon with:
/etc/init.d/sysklogd restart
Also, we should add a rule to ufw to allow incoming connections on UDP port 514:
sudo ufw allow 514/udp

Done!