How to resolve “mv: Argument list too long”

June 27, 2008

I have 1,30,000 files to move from one directory to another, When I ran command

# mv *.txt test

Oh!! There is an error

mv: Argument list too long.

What to do? I did it but in different way. I ran command

#find . -maxdepth 1 -name ‘*.txt’ -exec mv ‘{}’ test \;

Here

.                      defines search directory

-maxdepth     disables recursive search and searches only in the current directory. It allows you to control

how deep into sub directories it will recurs. With ‘-maxdepth’ 1 it will only search in current

directory.

-name             string to be searched

-exec              Applies a command to set of file that has been searched

{}                      Inserts each found file into given command after -exec

\;                     Indicates the exec command line has ended

The above example searches for *.txt files in current directory and moves it to the test directory.

More:    http://www.athabascau.ca/html/depts/compserv/webunit/HOWTO/find.htm


Setup proxy setting in a text based linux machine

June 24, 2008

Reference:

http://kryptoz.wordpress.com/2007/09/19/the-http_proxy-environment-variable-setup-proxy-setting-in-a-linux-machine/

If you need to use proxy server to access http/https from a linux machine in the office LAN, set the environment variable http_proxy. This will allow wget and python’s urllib modules and other applications (yum, apt-get etc) to use this environment variable and access http/https using the settings assigned to the variable http_proxy.

The below would be the ideal way of assigning values for http_proxy variable.

$export http_proxy=”http://<proxy-server-ip>:<port>”

I have added this to my ~/.bashrc so that I don’t have to export this variable every time I reboot my machine !

And then there is the “ftp_proxy” …..


Single-User Mode Require Authentication

June 20, 2008

By default on Red Hat Linux, user can enter single user mode simply by typing “linux single” at the GRUB boot-editing menu. Some believe that this is left in to ease support of users with lost root passwords. In any case, it represents a clear security risk – authentication should always be required for root level access. It should be noted that it is extremely difficult to prevent compromise by any attacker who has knowledge, tools, and full physical access to a system. This kind of measure simply increases the difficulty of compromise by requiring more of each of these factors. These last two items have attempted to address concerns of physical/boot security. To make these preparations more complete, one should consider setting the BIOS to boot only from the main hard disk and locking this setting with a BIOS password.

To set authentication for Single user mode edit /etc/inittab and add following line below initdefault.

id:3:initdefault

~~:S:wait:/sbin/sulogin

This will restrict Single User mode without authentication.


up2date command to update Redhat enterprise Linux (RHEL) how to

June 19, 2008

From: http://www.cyberciti.biz (Source)

For Redhat enterprise Linux operating systems, we need to get updates from RHN via Redhat Network Satellite/proxy servers (usually used by big hosting/ISPs or larget RHEL installation setups) to install critical and non-critical security updates as well as binary packages.

To register the system with RHN type the following command and just follow on screen instructions:

# up2date --register

WARNING! These examples only works with RHEL version 2.x, 3.x and 4.x only. RHEL version 5.x comes with yum utility to update and install packages.

Task: Display list of updated software (security fix)

Type the following command at shell prompt:# up2date -l

Task: Patch up system by applying all updates

To download all update type the following command:# up2date -u

Task: Forcefully update or patching

Sometime you need to forcefully apply updates. By default RHN does not install new kernel, so you need to run updates using following command:# up2date -uf

Task: Install new software/rpm

Use up2date command to install new RPM from RHN:# up2date httpd

Task: Update installed software

To fix latest bugs or to apply a patch use up2date command as follows for php package:# up2date php

Task: Download source RPM files

Download source packages only but don’t install:# up2date -d --src Package-Name

Task: Display the list of available packages

# up2date --showall
# up2date --showall | grep httpd

Task: Install particular architecture package

If you are using 64 bit RHEL version it is possible to install 32 packages:# up2date --arch=i386 mysql

Above command will install mysql 32 bit version instead of 64 bit version.

Task: Display what package provides the file

You can easily find out what RPM package provides the file. For example find out what provides the /etc/passwd file:# up2date --whatprovides "/etc/passwd"Output:

setup-2.5.37-1.3.noarch

It queries the RHN servers to resolve the comma separated list of dependencies. It will return a list of packages that will satisfy these dependencies.

Task: Display list of group software

Option –show-groups displays all the component groups that are installable via up2date command. This is good to install entire set of software such as development environment.
# up2date --show-groupsOutput:

Administration Tools
Arabic Support
Assamese Support
Authoring and Publishing
GNOME
GNOME Desktop Environment
GNOME Software Development
Games and Entertainment
Windows File Server
Workstation Common
X Software Development
X Window System
XEmacs

To install group X Software Development just type the command:
# up2date -i "@ X Software Development "

Read man page of up2date command for more information:
man up2date