Monday, July 28, 2008
Sunday, July 27, 2008
Save, Convert and join Youtube movies for playback on your Blackberry
to start first download the mencoder tool. It should be available in your distributions repository.
type apt-get install mencoder if you have a debian derivative distro or
type yum install mencoder if you have a red hat one.
When you watch a movie clip on you tube the .flv file is automatically saved into your /tmp folder so once you have watched a clip that you want, you can simply copy it from your /tmp folder and save it somewhere safe, youtube saves its files with a name that starts with Flash followed by some arbitrary characters like FlashFgna. Copy these files to another folder so that they do not get deleted as your system will delete all files in your /tmp folder when you log out. so for my example watch the four movies you want on you tube, each one in a different tab of your browser once you have watched all 4 movies, open up a terminal window
type cd ~ then type mkdir videos which will create the directory were we are going to be working in.
cd videos to cd into the folder
type copy /tmp/Flash* .
will copy the four .flv files to your /home/username/videos/ folder don't worry if you don't see the .flv extension they are .flv files Linux doesn't care for extensions.
Sometimes you can skip the following step and you can try and join and convert your Flash files from .flv to .mp4. using the mencoder tool. but I have been much more successfull first encoding the files to the .avi format and then if i want to put the file on my Blackberry i will encode from .avi to .mp4
to encode from Flash to .avi we need to create the tool that will convert flv to avi files, here is a script that can do this.
Copy the following lines into your clipboard by highlighting them directly from this post and hitting cntl- "c"
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 {-divx|-xvid} list_of_flv_files"
exit 1
fi
# video encoding bit rate
V_BITRATE=1000
while [ "$1" ]; do
case "$1" in
-divx)
MENC_OPTS="-ovc lavc -lavcopts \
vcodec=mpeg4:vbitrate=$V_BITRATE:mbd=2:v4mv:autoaspect"
;;
-xvid)
MENC_OPTS="-ovc xvid -xvidencopts bitrate=$V_BITRATE:autoaspect"
;;
*)
if file "$1" | grep -q "Macromedia Flash Video"; then
mencoder "$1" $MENC_OPTS -vf pp=lb -oac mp3lame \
-lameopts fast:preset=standard -o \
"`basename $1 .flv`.avi"
else
echo "$1 is not Flash Video. Skipping"
fi
;;
esac
shift
done
type vi /usr/local/bin/flv2avi.sh
(/usr/local/bin is a good place to save scripts as it is part of your path environment which means you will be able to execute your script from anywhere on your system)
this will open up your vi editor
once open type "i" to go into insert mode
then click on edit paste to paste the code into your script.
type :wq to save your script and exit out of vi
type chmod 755 /usr/local/bin/flv2avi.sh to make your script executable
to convert all the .flv files to avi we can do them all in one command. Type flv2avi.sh -divx Flashfile1 Flashfile2 Flashfile3 Flashfile4
were file1 file2 file3 file4 are the .flv files you want to convert.
once done you will have 4 additional files in your /home/username/videos folder all with .avi extensions.
now to join these files together and convert them to one .mp4 file which is the format that works best on your blackberry we also do it all in one command
mencoder file1.avi file2.avi file3.avi file4.avi -o newfilename.mp4 -ovc lavc -oac lavc
this will join all 4 files into one file and convert it to a .mp4 file
next just copy the file onto your blackberry and you will be able to play it using your blackberry's media player.
Saturday, July 26, 2008
Multiple Terminals in one Terminal Window with Terminator.
Friday, July 25, 2008
Session Managment with Screen
Screen is a window manager for your ssh terminal sessions. Screen is an absolute life saver when working over ssh as it allows you to reconnect to your sessions and continue working exactly were you left off. Screen allows you to re-attach to your session.
Screen is available in your Linux distributions repository. To install screen type
apt-get install screen if you are using a Debian based distro. Or yum install screen if you are using a red hat derivative distribution. You will want to run and install screen onto the machine that you are connecting to. Once installed start screen by typing screen.
If you are presented with a text message just hit enter. If nothing happens don't worry it just means that you are now inside a window within screen and it is running and working.
Screen supports multiple windows. This is useful for doing simultaneous tasks on the same machine over ssh without opening new sessions. Sometimes I need to run multiple tasks on the same remote machine or whilst one task is busy running I need to start up another task. Without screen I would need to make a new connection to the same machine or even more multiple connections and if any of the connections drop then i am screwed . With screen you connect to your remote machine only once and can run multiple tasks on the same connection and if your connection breaks, no problem you simply reconnect and re-attach your session.
To open a new window, you just use "Ctrl-A" "c"
run your task, eg mtr www.google.com
- Now open a new window with "Ctrl-A" "c" again and start another task this time lets start top type top
- To get back to your previous screen (mtr www.google.com task), use "Ctrl-A "n"
You can create multiple windows and toggle through them with "Ctrl-A" "n" for the next screen or "Ctrl-A" "p" for the previous one .
If you want to close your session but want to return to it later then you must detach from your session instead of closing it. This will leave your process running and will allow you to re-attach to the same process later. "Ctrl-A" "d". This will drop you into your shell. All screen windows are still there and you can re-attach to them later.
So you are using screen now and busy downloading a new program and suddenly your connection drops. Don't worry screen will keep the download going. Login to your system and type
screen - R to re-attach to your session and then use Ctrl - A "n" and "p" to toggle between all the sessions you were running on the remote system before your connection was lost.
another useful feature of screen is its ability to monitor a window for activity or for silence.
lets say you are downloading a file and you want to know when the download is finished, you will need to monitor for silence on that screen. To do that type "Ctrl-A" "_" . When your download is complete you will get an alert at the bottom with the window number. To quickly go to that window, use "Ctrl-A" " . After you do this, just type in the number of the window and enter. To stop monitoring, go to that window and undo the monitor with the same command. To monitor for activity type Ctrl-A "M" this will alert you when something new appears on the session that you wanted to monitor.
Screen can also be used to share a terminal session with another user. This is very useful if you need to show someone how to do something.
The host starts screen in a local xterm, using the command screen -S SessionName. The -S switch gives the session a name, which makes multiple screen sessions easier to manage.screen -S screendemo
ssh bwayne@cgerada.computer.ip.address
CTRL-A
:multiuser on
CTRL-A
:acladd bwayne
screen -x cgerada/screendemo
Voila both users will now share the same terminal session.
How to convert Multiple Images for emailing
apt-get install imagemagick for debian based distributions
or yum install imagemagick for red hat derivative distributions.
imagemagick is an awesome and extremely powerful image manipulation tool. For more detailed and other uses of this great tool read the man pages ie. man convert or visit their website http://www.imagemagick.org.
I use imagemagic to quickly resize a large batch of jpg files so that they are a suitable size for emailing
cd into the directory that you have your images saved, the ones you want to resize
then type the following
for k in $(ls *.jpg); do convert $k -resize 800x600 re_$k; done
replace 800x600 with whatever size you want to resize your images to. eg 640x480 or 320x200 etc this command will go through your current directory and will convert all your .jpg files by creating new files, saving the new converted files to a new filename with re_ infront of the existing file name. The original files are left intact.
you can also convert your pictures to different formats ie
convert image.jpg image.bmp
or convert image.gif image.tiff
or convert image.png image.jpg
will convert between the different formats
you can also use it to convert to a pdf file or to convert a pdf file to a jpg
eg convert file.jpg file.pdf or convert file.pdf file.jpg
Wednesday, July 23, 2008
How to Mount an ISO or an MDF image
in windows you need such tools as Daemon tools , Alcohol 120 etc to accomplish the same. In Linux it's a lot simpler. ISO images can be mounted without any additional tools. MDF images can also be mounted but they first need to be converted to an ISO file. To convert an MDF image to an ISO image use the mdf2iso tool which you can download from your distributions repository. eg yum install mdf2iso if you use a Red Hat derivative distro. Or apt-get install mdf2iso if you use a debian one. Once you convert the MDF file to an ISO you simply use the mount command to mount the image.
mount -t iso9660 -o loop
the loop option mounts the iso as a loopback device. This is neccassery when you are mounting a file of another file system in this case an iso file
mkdir /mnt/image
mount -t iso9660 -o loop /home/cgerada/films/the_dark_Knight.iso /mnt/image
The ‘-t’ option specifies the file type - this is optional, Linux is intelligent enough to see that the image you are mounting is of the iso9660 file type so you could just as well type.
mount -o loop /home/cgerada/films/the_dark_knight.iso /mnt/image
then cd into the /mnt/image directory to use the files ie cd /mnt/image.
To convert an MDF (alcohol 120) file to an ISO
type mdf2iso filename.mdf newfilename.iso
and then mount the ISO file.
Saturday, July 19, 2008
How to Upgrade your full distribution of Ubuntu to the latest version
sudo -i
enter your root password
apt-get install update-manager-core
do-release-upgrade
this will do a complete update to the latest version of Ubuntu, including updating of your sources list
on a desktop installation were you have Gnome or KDE installed press ALT -F2 then type
update-manager --devel-release and then click on run
this will also do a complete upgrade.
Friday, July 18, 2008
Look from 15 ft away
Wednesday, July 9, 2008
How to deny users access to certain sites at specific times
create a file in your /etc/squid/ directory called band_sites
you can do this by typing vi /etc/squid/band_sites
then in the empty file put a list of sites you want to ban your users from visiting
like so
myspace.com
facebook.com
youtube.com
save the file by typing :wq
change the ownership of the file so that the squid group can access the file
chown root.squid /etc/squid/band_sites
and then change the permissions to the file
chmod 640 /etc//squid/band_sites
edit your squid configuration file and then add the following ACL's.
It is important that you put these ACL's at the top
of the file, before your http_access allow our_networks
since ACL's are applied from top to bottom.
vi /etc/squid/squid.conf
acl work_time time 8:30-17:30
acl band_sites dstdom_regex -i "/etc/squid/band_sites"
http_access deny band_sites work_time
save your config file
and then reload squid by typing
/etc/init.d/squid reload
Done
Squid Proxy quick and easy
here's how to get squid up and running quickly.
Before activating squid you need to add three lines to the config file.
You need to add the hostname of your squid server. To do this add the following line to your
/etc/squid/squid.conf file , add it near the associated comment in the file.
were hostname.domainname.com is the host name of your squid proxy server.
visible_hostname hostname.domainname.com
Next you need to add the following basic access lists, so that your machines will be able to connect to squid.
acl our_networks src 192.168.0.0/24
http_access allow our_networks
were 192.168.0.0/24 is the address's of the machines that will be accessing your proxy server. You can add as many address ranges as you want. eg
acl our_networks 192.168.0.0/24 172.16.0.0/24 10.0.0.0/24
etc etc. save your changes and exit.
Make sure that you allow port 3128 on your firewall, as that is the default port that squid uses. You can change this port to anything you want like 8080 by editing the default port stanza in your /etc/squid/squid.conf file
type squid -z
this will create the squid swap directories.
Make sure that squid starts up on start up by typing
chkconfig squid on this will insure it starts on run levels 3 and 5
and then start squid by typing /etc/init.d/squid start
Done, squid should be up and running and caching webpages for your users.
Squid is a high performance very flexible and powerful caching proxy server
with many configurable options , for example, you can set up
password protected web browsing authentication for your users,
so that you can monitor web usage associated to login name, not only IP address. This is useful in an environment were more than one user uses the same machine. You can also restrict access to websites at certain times of the day for certain users.A comprehensive user guide on squid is available at http://euler.aero.iitb.ac.in/docs/web/squid/html/book1.html
Tuesday, July 8, 2008
Apache , how to password protect your site
edit your /etc/httpd/conf/httpd.conf file and add the following stanza
were the first line is the path of the directory you want to protect
</Directory"/var/www/html/website/">
AuthName "any Text in here you want to be displayed"
AuthUserFile /etc/httpd/webpass
Require valid-user
< /Directory >
once you have edited the file you will need to restart or reload the httpd daemon do this by typing
/etc/init.d/httpd reload
next type the following
htpasswd -c /etc/httpd/webpass username
were username is the username you want to allow access to the site
you will be prompted for a password for the username you entered and the information will be saved into the /etc/httpd/webpass file in an encrypted format, so even if someone reads that file they will not be able to make out what the password is.
If you want to add more authorised users to the file simply use the same command but without the -c option
-c was to create the original file , since it has now been created you just want to add users so you don't use the -c
eg htpasswd /etc/httpd/webpass username2when you access the site you will be prompted for a user name and password.
Monday, July 7, 2008
Logical Volumes LVM
if your data is stored on a logical volume and you run out of disk space, you can simply add more hard drives to your system and then grow your logical volume onto the new physical hard drives giving your data the extra space it needs, logical volumes can also work on top of Raid since logical volumes by them selves gives you no redundancy at all it is a good idea to have them setup on top of a Raid array.
To set up a logical volume partitions must first be converted into physical volumes using the pvcreate command. once you have added your new hard drives to the system, use fdisk to tag the drives as LVM's the tag hex code for LVM is 8e once tagged you can convert the drives to physical volumes to convert /dev/hda and /dev/hdb into physical volumes type:
pvcreate /dev/hda
pvcreate /dev/hdb
NOTE : to setup a LVM on top of a linux software Raid array you simply convert your software raid device to a physical volume eg:
pvcreate /dev/md0
Once you have one or more physical volumes created, you can create a volume group from these PVs using the vgcreate command.
vgcreate vg1 /dev/hda /dev/hdb
this creates a VG called vg1 from the two disks, /dev/hda and /dev/hdb
more PVs can be added to this volume group using the vgextend command.
pvcreate /dev/hdc
vgextend vg1 /dev/hdc
this will add /dev/hdc to the volume group "vg1"
to remove the PV from vg1 use the vgreduce command
vgreduce vg1 /dev/hdc
you can add as many disks to the volume as you like, think as the volume
as your cache of storage.
Use lvcreate command to create a logical volume which will use the free capacity in the volume group pool. (ie your storage cache)
lvcreate -n lv1 -L 100G vg1
or you can specify the capacity in PE's "physical extents" to find out how many PE's are available
in your volume group type.
vgdisplay vg1 | grep "Total PE"
which returns
Total PE 34456
Then use lvcreate to create a logical volume with 34456 extents
lvcreate -n lg1 -L 34456 vg1
you can also allocate a logical volume from a specific physical partition in the volume group by specifying the partition at the end of the lvcreate command.
lvcreate -L100G -n lg1 /dev/hda /dev/hdb
A logical volume can be removed from a Volume group using lvremove
you must first umount the logical volume.
umount /dev/vg1/lg1
lvremove /dev/vg1/lg1
when you add more hard drives to your system and add them to the Volume group you can then extend the logical volume to make use of the added storage by using the lvextend command. You can specify either an absolute size for the extended LV or how much additional storage you want to add to the LV.
lvextend -L120G /dev/vg1/lg1
will extend the logical volume to 120 GB, while
lvextend -L+20G /dev/vg1/lg1
will extend the logical volume by an additional 20 GB. Once a logical volume has been extended, the file system must be expanded to use the added storage.
to do this use the resize2fs command.
resize2fs /dev/vg1/lg1your done...
other usefull commands
pvs will list all your partitions that you have assigned to a volume group
lvs will list all of your configured logical Volumes
vgs will show you how much available or free space you have available in your volume group
lvscan will scan for active logical volumes
vgdisplay will display the information of your volume group
lvdisplay will display currently configured logical volumes
For a good guide to grow a Virtual Machine checkout the following link
http://www.jaredlog.com/?p=1133
Saturday, July 5, 2008
Software raid on Linux
first you will need the partitions available to you for the raid, using fdisk you must tag the partitions with the "linux raid autodetect " tag using the hex code id of fd to do this just type fdisk /dev/hda (you use the name of the partion you want to tag then type t and then type fd type w to save and then type partprobe to probe the changes into your kernel
next you need to create your raid partition , lets create a raid 1 partition which is a mirrored set and it uses 2 disks, but we are going to add a 3rd disk and use it as a spare, so if one of the 2 disks in the mirror break the spare will automatically replace it in the raid configuration and rebuild itself.
so we have 3 partitions taged with the "linux raid autodetect" tag id fd
to create a raid 1 partition we type mdadm -C /dev/md0 -l 1 -n 2 -x 3 -a yes /dev/hd{3..5}
-C = create
-l 1 = raid level 1
-n 2 = how many disks we will be using
-x 1= x stands for spare (how many spare disks we will be using
-a yes = instructs udev to create the md device file if it does not already exist
/dev/hd{3..5} are the disks you want to use in the raid you could type them separately ie /dev/hd3 /dev/hd4 /dev/hd5 if you want but /dev/hd{3..5} is shorter to type and is the exact same thing.
once done you need to format your raid partition.
mkfs.ext3 /dev/md0
next create a directory were you want to mount your raid partition
mkdir /media/raid1
lets give the partition a label we will use the label name in the fstab file this is not necessary however it is good practice to label your partitions so that if they ever change their /dev position the label will remain the same and they will still mount.
e2label /dev/md0 raid1
then we can mount it in fstab using its label name ... in your /etc/fstab file add the following line
LABEL=raid1 /media/raid5 ext3 defaults 1 2
save your fstab file and type mount-a to have your fstab file read and loaded by the system
to monitor our raid partition we can type cat /proc/mdstat
or watch -n1 cat /proc/mdstat this will update the monitoring process every second
you can even simulate a drive failure to test if your raid works,
type watch -n1 cat /proc/mdstat in a terminal window and set that window to always be on top , then open another window to fail your drive in and you can watch your raid rebuild itself in the monitoring window.
in the other window type mdadm /dev/md0 -f /dev/hd3 (this will fail drive /dev/hd3 in your raid)
(watch what happens in your monitoring window) you can then remove the failed drive from the raid set by typing mdadm /dev/md0 -r /dev/hd3
and to put a new drive back into you raid set type mdadm /dev/md0 -a /dev/hd3
Friday, June 27, 2008
Setting up and Managing Disk Quota's
edit your /etc/fstab file and edit the line for your /home or your / partition and add the usrquota option like so
/dev/hda/ /home ext3 defaults,usrquota 1 2
save your fstab file and then type
mount -a
so that the fstab files changes are read by the kernel
next
type quotacheck -cugm
this will scan the quota file system and is necessary to run first before you can add quota's
c = create files
u = scan user quota's
g= scan group quota's
m= no remount
then to add a quota type the following substitute "username" for the username you want to add the quota for
edquota -u username /home
vi will then open the quota file for that user that looks like this
Disk quotas for user username (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/hda 707896 0 0 13 0 0
simply edit the file to the settings you want. A soft limit is your warning limit and a hard limit is your never exceed limit. blocks are storage size 1000 blocks is equal to roughly 1MB and you can restrict the user to number of inodes each file uses 1 inode. large amounts of small or empty Files can also fill up a file system , since an empty file still requires an inode so if you set a hard limit on the inodes of say 1000 that means the user will only be able to save a maximum of 1000 files in their home folder even if the files are of 0kb in size.
to limit a user to say 1GB of storage set the hard limit of the blocks to 1000 000 as 1000 blocks is equal to roughly 1MB , so to limit them to 100MB set the hard limit to 100 000 blocks
save the file by typing :wq
to see what quota's have been set and to see the usage by users on all file systems, type repquota -a
a user can also see their own quota statistics by typing quota
or root can type quota -u username
You can also use the setquota command, to set a users quota (instead of edquota)which has the advantage of not using an editor making it ideal for implementing in a script. For example, to set the soft block limit to 100, a hard block limit of 200, a soft inode to 10 and a hard inode to 15 , execute the following command.
setquota -u username100 200 10 15 -a /home
Monday, June 16, 2008
How to further Secure your Server for SSH
is the name of your server that is available on the Public Internet to you from your local machine using SSH
although SSH in itself is a secure protocol to use as it encrypts the user names and passwords, to further protect your server from brute force attacks as well as to insure that even if a hacker decrypts the user name and password of your connection he will still not be able to take over your machine with admin privileges follow these steps.
since port scanning is so easy to do, i do not recommend bothering changing your default ssh port to another port, it will take a hacker all of 1 millisecond to find out what port you have changed to.
create a Private / Public Key pair on the computer that you use that you want to connect from
to do this type ssh-keygen
you will get the following response
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
hit enter to have your keys saved in /root/.ssh/ directory (this directory will be off the home directory of the user that you were when you ran the ssh-keygen command in my case i was the root user
next you will be asked if you want to create a pass phrase for the key
Enter passphrase (empty for no passphrase):
here you can enter a password , remember this password is for the key (should your local computer be compromised and someone steals your private key, they will still need to know what the password is)
or you can leave the password out, it is useful to leave the password out if you are using this technique to automate an ssh connection for the purpose of file transfer using a cron job ill explain how to do that in another posting)
once the key is created you need to transfer the public key to your server1.hq.org which after all is the server you want to secure. To do that enter the following
ssh-copy-id -i root/.ssh/id_rsa.pub username@server1.hq.org
were root/.ssh/ is the folder were your keys were saved to.
the ssh-copy-id command will transfer the public key to your server and save it into the correct folder,
you could manually use scp to copy the key accross but ssh-copy-id does it all for you and puts the key were it should be.
now you will be able to connect to your server without logging in, once connected to your server you need to edit your /etc/ssh/sshd_config file use your favourite editor to edit this file and add the stanza PermitRootLogin no
save your file, and then reload the sshd service by typing /etc/init.d/sshd reload this will load in the new settings from now on you have to connect to your server over ssh using a standard user account, once you are on the server you can sudo to the root user to perform admin tasks, the reason why we do this is in case a hacker decrypts the secure ssh password he will still only have access to a non privileged user account which is better than if they were to compromise your server with your admin password.
Forwarding Ports over SSH
ssh -L 5901:remote-server:5901 user@ssh-remote-server
once the connection has been made over ssh and you have authenticated with your ssh password,
simply fire up your application that requires the remote port and point it to your localhost port 5901 and it will be tunneled over the ssh connection. in this example we tunneled vnc over ssh to make the connection
simply type vncviewer localhost:1
the remote server will think that the connection has been initiated from the local server on its network (the ssh server)
another example lets say you want to browse a web server on a remote machine through your local port 8080
ssh -L 8080:remote-server:80 user@ssh-remote-server
once you have authenticated on ssh, open up your browser and type http://localhost:8080 in your address bar, you will access the web-page of the remote server:80
the added advantage of doing this is that your tunnel is encrypted and traffic travelling between your local and remote machines is secure.
Access Control Lists (ACL's)
however if a standard user wants to allow access to a folder to one of his colleagues
you must use ACL Access control list
first off acl needs to be instated on the mounted file system that you want to allow users to manage their own permissions on, to do this edit your /etc/fstab file and make sure that that you add the acl option to the mount so that it looks something like this
/dev/hda /home ext3 defaults,acl 1 2
save your fstab file and force the Kernel to re-read its contents by typing
mount -a
this will read in the contents of your fstab file and remount all the file systems with the the new settings.
then for a standard user to give access to a certain folder they must use the setfacl command
so to give user2 read write access to /home/user1/projects folder user 1 would type
setfacl -m u:user2:rw /home/user1/projects
the m stands for modify. to remove permissions you would replace the m with an x and then simply state the folder you wanted permissions removed from
eg setfacl -x /home/user1/projects
you could set permissions to individual files as well not only directories
eg setfacl -m u:user2:rw /home/user1/projects/filename
you can set permissions using rwx notation as well for example
To deny a user acces to a file type the following
setfacl -m u:user2:---/home/user1/projects/filenameto give him read access only you can type the following
setfacl -m u:user2:r--/home/user/projects/filename
if you want to see what permissions exist on a certain folder
type getfacl /home/user1/projects
you should get a response similar to the following were you can see the added permissions for user 2
# file: home/user1/project
# owner: user1
# group: user1
user::rwx
user:user2:rw-
group::r-x
mask::rwx
other::r-x
To do the same to a samba share so that Windows users are controlled by the ACL
do the following
Add ACL support to a Partition:
1. vim /etc/samba/smb.conf
In share you want ACL support add: nt acl support = yes
2. To add access to a group to a folder:
setfacl -m g:GROUPNAME:rwx FOLDERPATH
OR To add access to a user to a folder:
setfacl -m u:USERNAME:rwx FOLDERPATH
3. Remove Permissions for others:
chmod 770 FOLDERPATH
4. Check permissions:
getfacl FOLDERPATH
5. Remove ACL:
setfacl -d acl-entry
ex: setfacl -d g:GROUPNAME FOLDERPATH
Sunday, June 15, 2008
DMIDECODE
use dmidecode,
dmidecode will dump the systems DMI contents in a human readable format , This information includes system manufacturer, model name, serial number, BIOS version, asset tag as well as a lot of other details of varying level of interest and reliability depending on the manufacturer. This will often include usage status for the CPU sockets, expansion slots (e.g. AGP, PCI, ISA) and memory module slots, and the list of I/O ports (e.g. serial, parallel, USB).
lets say a remote client wants to upgrade their memory and they call you to order more memory, but they have no idea if their machine takes dimms or simms or if it even has any available slots left you can simply ssh into their machine type 'dmidecode | less' at the command line and you will know exactly what memory the machine takes and what slots are free as well as a wealth of information about the other hardware attributes of the machine.
CHKCONFIG on Ubuntu
$ apt-get install libnewt0.52
$ ln -s /usr/lib/libnewt.so.0.52 /usr/lib/libnewt.so.0.50
$ wget http://www.tuxx-home.at/projects/chkconfig-for-debian/chkconfig_1.2.24d-1_i386.deb
$ dpkg --force-all -i chkconfig_1.2.24d-1_i386.deb
usage of chkconfig is as follows
chkconfig --level 0123456 program_name on
will turn on program_name so that it starts up on all runlevels, this is a bad example since you would seldom want an app or service to run on runlevel 0 (shutdown) or run level 6 (reboot)
chkconfig --list
will show you a comprehensive list of all services / programs and what run levels they will start on.
another easy to use tool for editing runlevels is sysv-rc-conf
to install
apt-get install sysv-rc-conf
and then just type sysv-rc-conf
gives a very easy to use interface for managing your runlevel symlinks
Saturday, June 14, 2008
Disable Caps Lock
The only time I use the caps lock button on my keyboard is when I accidentally press it and start typing in UPPERCASE. To disable it in Linux all you have to do is enter this on the command line:
$ xmodmap -e "remove lock = Caps_Lock"
To set this permanently, paste the above line in your ~/.bashrc file
or if you are a vim user and you want to swap caps lock for your escape key
do the following
create the following file in your home directory
.Xkbmap
-option caps:swapescape
or if you don't want to swap the two keys around, instead you just want caps lock to behave the same as escape and escape key to still be the escape key.
Then put the following line in instead
-option caps:escape
The next time you log-in into an X session, the changes will take effect. Alternatively you can just run the command
setxkbmap`cat ~/.Xkbmap`
and the changes will take effect immediately.
