≡ Menu

linux operating system

Ubuntu Linux: Add a User To Group

How do I add a user to group under Ubuntu Linux operating system using command line options?
[click to continue…]

Howto: Send The Content Of a Text File Using mail Command In Unix / Linux

I'd like to send an email with the content of a text file using mail command in Unix / Linux operating system. How do I do it?
[click to continue…]

HowTo: UNIX / Linux Open TCP / UDP Ports

How do I open the TCP or UDP ports under UNIX / Linux like operating systems?
[click to continue…]

Shell Scripting: Check File Size ( Find File Size )

How do I find out file size under UNIX / Linux operating system and store the same to a variable called s?
[click to continue…]

Find and Delete File If It Is More Than One Hour Old in UNIX Shell

Q. How do I find out file last modification time using a shell script or command? How do I delete or take any other custom action for all files more than one hour old in /home/ftp/incoming/raw/ directory?
[click to continue…]

UNIX: Remove A File With A Name Starting With – (dash) Character

I am a new Unix shell user at my university shell server. Accidentally, I had created a file called -foo. Now, how do I remove a file with a name starting with '-' under UNIX-like or Linux operating system?
[click to continue…]

Debian / Ubuntu Linux Connect to an iSCSI Volume

Q. How do I format and connect to an iSCSI Volume under Debian / Ubuntu Linux?

A. You need to install open-iscsi package for high performance, transport independent iSCSI implementation under Debian / Ubuntu Linux. This package is also known as the Linux Open-iSCSI Initiator. You need Linux operating system with kernel version 2.6.16, or later. See REHL 5 / CentOS 5 / Fedora Linux specific instructions here.

Install Open-iSCSI Initiator

Type the following command at a shell prompt:
$ sudo apt-get install open-iscsi

Open-iSCSI default configuration

You need to soft-link (path fix) few two files to autologin work i.e. fix file paths for iscsiadm, enter:
ln -s /etc/{iscsid.conf,initiatorname.iscsi} /etc/iscsi/
Default configuration file could be located at /etc/iscsi/iscsid.conf or ~/.iscsid.conf. Open /etc/iscsi/iscsid.conf file:
# vi /etc/iscsi/iscsid.conf
Set node.session.auth.username, node.session.auth.password and other parameter as follows:
node.startup = automatic
node.session.auth.username = MY-ISCSI-USER
node.session.auth.password = MY-ISCSI-PASSWORD
discovery.sendtargets.auth.username = MY-ISCSI-USER
discovery.sendtargets.auth.password = MY-ISCSI-PASSWORD
node.session.timeo.replacement_timeout = 120
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.noop_out_interval = 10
node.conn[0].timeo.noop_out_timeout = 15
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.conn[0].iscsi.MaxRecvDataSegmentLength = 65536

Save and close the file. Restart open-iscsi service:
# /etc/init.d/open-iscsi restart
Now you need to run a discovery against the iscsi target host:
# iscsiadm -m discovery -t sendtargets -p ISCSI-SERVER-IP-ADDRESS
If is iSCSI server IP address, enter:
# iscsiadm -m discovery -t sendtargets -p
# iscsiadm --mode discovery --type sendtargets --portal
Note down the record id (such as iqn.2001-05.com.doe:test) found by the discovery. You need the same for login. Login, must use a node record id found by the discovery:
# iscsiadm --mode node --targetname iqn.2001-05.com.doe:test --portal --login
Finally restart the service again:
# /etc/init.d/open-iscsi restart

Format iSCSI Volume

Now you should see an additional drive on the system such as /dev/sdc. Use /var/log/messages file to find out device name:
# tail -f /var/log/messages
If your device name is /dev/sdc, enter the following command to create a partition:
# fdisk /dev/sdc
Next format partition:
# mkfs.ext3 /dev/sdc1
Mount file system:
# mkdir /iscsi
# mount /dev/sdc1 /iscsi

List or Check Installed Linux Kernels

Q. How do I list all installed kernel on Linux operating system? How do I find out current kernel version?

A. You can use standard package listing command to list installed kernels.

RedHat / CentOS / RHEL / Fedora Linux user

You need to use standard rpm command to list installed software. Type the following command at shell prompt:
$ rpm -qa kernel


To list / display current kernel

Type the following command:
$ uname -r
$ uname -mrs


Linux 2.6.18-8.1.14.el5 x86_64

Debian / Ubuntu Linux user

Use dpkg command to list all installed kernel, enter:
$ dpkg --list | grep linux-image

ii  linux-image-2.6.20-15-generic        2.6.20-15.27                           Linux kernel image for version 2.6.20 on x86/
ii  linux-image-2.6.20-16-generic        2.6.20-16.32                           Linux kernel image for version 2.6.20 on x86/
ii  linux-image-generic                                 Generic Linux kernel image

Ubuntu Linux: Start / Stop / Restart OpenSSH ( SSH ) Server

I need to provide a remote access to my Ubuntu Linux based server. How do I start / stop OR restart the ssh server under Ubuntu Linux operating system using command line options?
[click to continue…]

Redhat enterprise Linux / CentOS installing kernel source code

Q. How do I install Linux kernel source code and headers under RHEL 5 or CentOS 5 Linux operating system?

A. Both CentOS and RHEL 5 includes following packages:

a) Kernel-headers : It includes the C header files that specify the interface between the Linux kernel and userspace libraries and programs. The header files define structures and constants that are needed for building most standard programs and are also needed for rebuilding the glibc package.

b) kernel-devel : This package provides kernel headers and makefiles sufficient to build modules against the kernel package.

c) Actual kernel source code : You can always download actual source code here. Look for kernel*.rpm file.

Rhel / CentOS 5 install kernel headers

Use yum command as follows:
# yum install kernel-devel Kernel-headers

Install kernel source code

Type the command as follows:
# cd /tmp
# wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/kernel-2.6.18-8.1.8.el5.src.rpm
# rpm -ivh kernel-2.6.18-8.1.8.el5.src.rpm

Note change version number as per your current kernel.

For recompiling or adding a new module or device driver you just need kernel-devel and Kernel-headers packages. To rebuilt kernel rpm goto /usr/src/redhat/SPECS directory, modify kernel spec file and use rpmbuild command to rebuild rhel/centos kernel rpm.