Tuesday, November 27, 2012

VLC media player 0.9.2

VLC media player 0.9.2
VLC media player 0.9.2
The best media player in my book, VLC has a new version out. Like WL it’s my player of choice on both my Linux and Windows machines.
Read the changelog while you download the installer.

How to find your Ubuntu version

2 easy ways find out what version of Ubuntu you’re running.
First option,
cat the /etc/issue file.
danny@family-desktop:/etc$ cat /etc/issue
Ubuntu 8.04.1 n l

Second option
cat the /etc/lsb-release file.
danny@family-desktop:/etc$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.1"

or
run the lsb_release command with the “-a” switch.
danny@family-desktop:/etc$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 8.04.1
Release:        8.04
Codename:       hardy

How to give someone root access in Linux

Giving someone root access in linux is easy. Why would someone need to be root I don’t know but this is how you do it using the usermod command.
To add root access
[root@abika root]# id sys_admin
uid=508(sys_admin) gid=508(sys_admin) groups=508(sys_admin)
[root@abika root]# usermod -G root sys_admin
[root@abika root]# id sys_admin
uid=508(sys_admin) gid=508(sys_admin) groups=508(sys_admin),0(root)

To remove root access.
[root@abika root]# usermod -G sys_admin sys_admin
[root@abika root]# id sys_admin
uid=508(sys_admin) gid=508(sys_admin) groups=508(sys_admin)

cannot allocate memory error

Had a weird memory error my Linux servers at work today. These were heavy duty machines running  heavy jobs throughout the day. /var/log/messages kept reporting that the kernel had no more memory to process new jobs. Most of the errors read ” cannot allocate memory ”
Some digging around later we found the fix. Kernel 2.6 has a new parameter “min_free_kbytes” which allows it to reserve a dedicated amount of memory for itself to process jobs. This kept the kernel from choking up when the servers were faced with sudden spikes in heavy jobs.
I set my server’s  “min_free_kbytes” to “4096″ kbytes which was the recommended value. It’s more of a trial and error configuration so I’ll have to monitor the server over a period of time and increase the value if needed till I hit the sweet spot.
How to set it?
To have the new value take effect immediately, edit the “/proc/sys/vm/min_free_kbytes” file. Remember!, reboot and the changes will be forgotten.
echo "4096" > /proc/sys/vm/min_free_kbytes
To have it permanent, add “vm.min_free_kbytes=65536″ to the /etc/sysctl.conf file.
echo "vm.min_free_kbytes=4096" >> /etc/sysctl.conf

Get your PID with $$

“$$” is a useful Linux variable you could use in your script to get it’s PID. The “$$” variable always holds the PID of the executing process.
Why do you need it? Maybe to check if the script is already running? This is what I normally use it for.
Sample Script;
#!/bin/bash
echo "My PID is $$"
sleep 2

Sample Output;
[root@keke ~]# ./test1.sh
My PID is 8909

System uptime with uptime

Want to know how long your Linux box has been up for?
Simple, just run the “uptime” command and you will be rewarded with the answer plus a bit more.
8:58pm  up  19:54,  1 user,  load average: 0.47, 0.62, 0.35
Above is the typical reply from uptime. On the left is the current time, followed by the system’s uptime, logged in users and finally the system’s load average.
Sample output;
danesh@pandora:~> uptime
8:58pm  up  19:54,  1 user,  load average: 0.47, 0.62, 0.35

Simple sort with the sort command

You can easily sort your outputs in Linux using the “sort” command. Simply pipe “|” your output to a “sort” command and you should see the sorted results.
See sample usage below. This is just to start off, I’ve cover more in future posts.
[root@hantu ~]# cat numbers
5
4
3
2
1
0
6
7
8
9

[root@hantu ~]# cat numbers | sort
0
1
2
3
4
5
6
7
8
9

[root@hantu ~]# cat numbers | sort -r
9
8
7
6
5
4
3
2
1
0

Happy sorting!!