Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, August 15, 2014

Create swap file for your VPS

Just got a VPS for your own use? RAM only 512MB? or maybe you are accustomed to out of memory error and need a way to increase your memory.
Then you got to have a swap file for your VPS, the size of which will depend on your usage.

One thing to remember, swap file is created on your storage. So don't expect it to be as fast as your RAM.

Here are the steps you can follow (works on Ubuntu 12.04):
1. Check for existing swap file, if you already have one then all are good.
    swapon -s

2. Create your file for the swap file
sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k

3. Set it as swap file
sudo mkswap /swapfile

4. Register the swap file
sudo swapon /swapfile

5. Make it permanent on the system
sudo nano /etc/fstab

And add the following line at the end:
/swapfile       none    swap    sw      0       0 

6. Set the swappiness
echo 10 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf

7. Protect the file
sudo chown root:root /swapfile 

sudo chmod 0600 /swapfile


That's all, enjoy your VPS.

Reference:
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-12-04

Monday, July 07, 2014

Configure reverse ssh tunneling

When you have a need to access your local PC from the internet, you might be interested in this blog.

Requirement:
1. Root access to a public server (or any kind of access as long as you can do things below :).
2. SSH client


Now, let's begin with the server:
1. Edit sshd_config located in /etc/ssh/ and add the line below
GatewayPorts clientspecified

2. Restart sshd
sudo service ssh restart

That's all for the server.


To the local PC we go:
1. Create reverse ssh tunneling using ssh client.
Open a terminal/console to run the ssh client. In windows you might use Putty.
ssh user@server -R server:serverport:localdestination:localport

2. Test the connection by using telnet
telnet server serverport
Expect no connection refused :)


The steps above is very simple but requires some configuration changes in the public server.
There's a more secure way but requires more effort on the client side which means only geek will be able to access it :) I'll discuss it later on a separate blog.

Setting up vnc for ubuntu desktop

If your installation is ubuntu desktop and you need to remote it using vnc, the steps below might help you to do it:
1. Update your package list
sudo apt-get update

2. Install Gnome desktop environment essential component and Gnome session manager
sudo apt-get install gnome-core gnome-session-fallback

3. Install vnc server
sudo apt-get install vnc4server

4. Start the vnc server
vncserver 
Note: find out the console port being assigned to you. There is a way to start up the connection with a pre defined port number (e.g. vncserver :1)

Example: the assigned port is 1 (5901)
New 'server:1 (server)' desktop is server:1

Starting applications specified in /home/user/.vnc/xstartup

Log file is /home/user/.vnc/user:1.log

5. Edit the xstartup file located /home/user/.vnc/ as below.
At first, when you open the vnc connection there will be only a terminal. You will need to start the gnome-session for the vnc connection.
#!/bin/sh

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

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &

gnome-session --session=gnome-classic &

6. Restart the vncserver by killing it first then starting it up again
vncserver -kill :1


To access vnc from the client, you need to install vnc viewer app. 
The sample url for vnc: server_url:5901
the port number is assigned when you start the vnc connection.


Up to now, for ubuntu server I use Xfce desktop environment instead of gnome. It is lightweight and somehow I still can't setup the gnome env under vnc :)


Reference link:
http://coddswallop.wordpress.com/2012/05/09/ubuntu-12-04-precise-pangolin-complete-vnc-server-setup/

Friday, December 03, 2010

Configuring mic in aspire 4741z - ubuntu 10.10

Luckily for me, my installed alsa is already the latest one. All that is needed is just to add 2 lines below to /etc/modprobe.d/alsa-base.conf

alias snd-card-0 snd-hda-intel
options snd-hda-intel model=acer


My mic works now but it seems a bit quiet. Hopefully I can find the way to boost the mic.

A nice tool that might help is alsamixer, run it from a terminal.

Tuesday, November 30, 2010

Ubuntu 10.10 brightness problem in Acer Aspire 4741

To those who have problem with brightness configuration after installing Ubuntu 10.10 and you are using Acer Aspire 4741, here's a solution for you:
  1. sudo gedit /etc/default/grub
  2. Change the line GRUB_CMDLINE_LINUX="" into
    GRUB_CMDLINE_LINUX="acpi_osi=Linux"
  3. sudo update-grub
  4. Restart your linux

Hopefully it helps.

Tuesday, April 27, 2010

Configuring static IP in Fedora

If all you have is a CLI, then you might find this to be of benefit. Otherwise you could just use the Network Device Control GUI.

Here are the steps:
  1. Execute ifconfig and find out your ethernet configuration name (e.g. eth0)
  2. Go to /etc/sysconfig/network-script
  3. edit ifcfg-eth0 (depends on your ethernet)
  4. Update the file as follow (set the IPADDR, BROADCAST according to your desired configuration)

  5. Restart the network service
    service network restart

Here's a brief explanation on the configuration:
  • BOOTPROTO : telling the network that we're configuring it as static ip
  • ONBOOT : the configuration will be set at boot time
  • BROADCAST : your gateway
  • NETMASK : your netmask


.