≡ Menu

less command

I am a new Unix system admin. How do I find ouw who has recently use the Linux or Unix-like server? Which terminals they used, and when they logged in and out of the my server?
[click to continue…]

How do I see a list of all exported variables and functions under Unix bash shell?
[click to continue…]

OpenGL (Open Graphics Library) is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. How can I test if my graphics card has OpenGL support under Linux?
[click to continue…]

Linux: List / Display All Cron Jobs

How do I view currently setup or all running cron jobs under a Linux or Unix-like operating systems?
[click to continue…]

I can use less or more pagers to view a file. How do I start an editor (such as vi or other text editor) to edit the current file without leaving the less or more pager command?
[click to continue…]

Linux: Display rpm package architecture

Q. I’m using CentOS on 64 bit Linux. How do I find out rpm package architecture before installation such as i386 or x86_64 bit?

A. Almost each rpm package has i386 or x86_64 added to file extension. However some time you may see filename such as file-version.rpm. You can list all installed rpm packages with rpm -qa command but it will not display architecture. You can run following command to display rpm package architecture:
rpm -qa --qf "%{n}-%{arch}\n"
Ouput:

filesystem-x86_64
comps-extras-noarch
gnome-mime-data-x86_64
glibc-x86_64
atk-x86_64
libICE-x86_64
db4-x86_64
elfutils-libelf-x86_64
ncurses-x86_64
libsepol-x86_64
libcap-x86_64
sqlite-x86_64
pcre-x86_64
gdbm-x86_64
libsepol-i386
libXdmcp-x86_64
db4-i386
iptables-x86_64
libXrender-x86_64
libXi-x86_64
xorg-x11-font-utils-x86_64
slang-x86_64
libXpm-x86_64
startup-notification-x86_64
gzip-x86_64
libIDL-x86_64
libXau-i386
wireless-tools-x86_64
libvorbis-x86_64

Another option is to use following command to display detailed information about package:
rpm -qi {package-name}
If you wish to display package version along with architecture, enter:
rpm -qa --qf "%{n}-%{v}-%{r}.%{arch}\n" | less
Run rpm command to print a list of all of the tags it knows about when it is invoked with the --querytags argument.
rpm --querytags | less

Howto: Changing Linux Login Shell

Q. Can you tell me command to change login shell in Linux / UNIX operating system?

A. You don't have to edit /etc/passwd file to change your shell. You need to use chsh command. It changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for his/her own account, the super user i.e. root user may change the login shell for any account. Following is syntax of chsh command:
chsh -s {shell-name} {user-name}

Where,

  • -s {shell-name} : Specify your login shell name. You can obtained list of avialble shell from /etc/shells file.
  • User-name: It is optional, useful if you are a root user.

First, find out available shell list:
$ less /etc/shells

Output:

/bin/ash
/bin/csh
/bin/sh
/usr/bin/es
/bin/ksh
/bin/tcsh
/bin/sash
/bin/zsh
/bin/dash
/usr/bin/screen
/bin/bash
/bin/rbash

Now change your shell name to /bin/tcsh:
$ chsh -s /bin/tcsh
Password:

When promoted for password, type your own password. If you just type chsh command, it will prompt for shell name interactively:
$ chsh

Output:

Password:
Changing the login shell for tv
Enter the new value, or press ENTER for the default
       Login Shell [/bin/bash]: