Archive for the ‘Unix/Linux’ Category

Unix/Linux — Ubuntu/Debian — lock package version

October 11, 2011

In order to lock a package to a specific version and refrain it from being upgraded do:

sudo -s
echo PACKAGE_NAME hold | dpkg --set-selections

To verify the settings for a package to:

sudo -s
dpkg --get-selections PACKAGE_NAME

To re-enable a package to be upgraded do:

sudo -s
echo PACKAGE_NAME install | dpkg --set-selections

More info can be found here:
https://help.ubuntu.com/community/PinningHowto

Unix/Linux — .Xdefaults in X-Win32

February 27, 2011

In order to be able to use your .Xdefaults file in X-Win32 you have to do the following.

  1. Copy your .Xdefaults file to C:\Users\USERNAME\AppData\ Local\StarNet\X-Win32\Xdefaults. Where USERNAME is your Windows user name.
  2. Disable the Set Xresource Defaults option in the X-Win32 X-Config’s Window tab.

Unix/Linux — Swap Ctrl and Caps Lock in X11

April 26, 2008

In order to swap the Ctrl and Caps Lock keys in X11, you can add the following line in Section “InputDevice” of file /etc/X11/xorg.conf:

Option “XkbOptions” “ctrl:swapcaps”

If you woud like to keep the Ctrl where it is and make Caps Lock act as a Ctrl also, you can add:

Option “XkbOptions” “ctrl:nocaps”

Unix/Linux — generate large file

April 11, 2008

In order to generate a large file of a set size you can use:

dd if=/dev/zero of=test100M.bin bs=100000000 count=1

where of is the output file and bs is its size in bytes.

Unix/Linux — Redirect output with sudo

September 26, 2007

Sometimes you might need to redirect the output with sudo privileges. For example:

echo myhost.com > /etc/hostname

will give you the following error:

-bash: /etc/hostname: Permission denied

Unfortunately, using:

sudo echo myhost.com > /etc/hostname

will give the same error.

The solution is to start bash as sudo and then give the entire command to bash as input:

sudo bash -c “echo myhost.com > /etc/hostname”

Or as one reader suggested:

echo myhost.com | sudo tee /etc/hostname

Unix/Linux – ICS printer name

May 26, 2007

To get a list with all the printers in ICS, ssh to printserver and run:

lpstat | grep Printer

Unix/Linux — Bash — String seperator

November 6, 2006

In Bash the default string separator is whitespace which means spaces, tabs, or blank lines. The string separator is used in various places, including when looping with for over a string. The string separator is stored in the IFS variable.

If you want to set the default separator to “:” you need to do:

IFS=:

If you want to set is to newline, you can do it like this:

IFS=$’\x0a’

‘\x0a’ is the hexadecimal notation for newline or Ctrl-J.

A common pattern is to save the old separator before changing and restore it when you are done:

IFS_OLD=$IFS
IFS=:

IFS=$IFS_OLD

or more simple, just unset it when you are done:

IFS=:

unset IFS

Unix/Linux – ICS quota

October 11, 2006

To view your quota, use the following command on a Sun OS system:

quota -v

The command will not display the correct information on the Linux systems.

The get the amount of free space on a shared disk, use, for example:

df -h /extra/rvernica0

Unix/Linux – output the Nth line from a file

October 2, 2006

In order to output the Nth line from a file you can use:

more +N file | head -n 1

Linux – print system information

September 12, 2006

To print system information in Linux, you can use:

uname

E.g.,

uname -a

will print the kernel version.