chmod command

06.06.2009

14>chmod command.

SUMMARY:

chmod is a Unix command that lets you tell the system how much (or little) access it should permit to a file.
This manual page documents the GNU version of chmod. chmod changes the permissions of each given file according to mode, which can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new permissions.

SYNTAX:

-c, –changes     like verbose but report only when a change is made
–no-preserve-root     do not treat `/’ specially (the default)
–preserve-root     fail to operate recursively on `/’
-f, –silent, –quiet     suppress most error messages
-v, verbose     output a diagnostic for every file processed
–reference=RFILE     use RFILE’s mode instead of MODE values
-R, –recursive     change files and directories recursively
–help     display this help and exit
–version     output version information and exit

Permissions
u – User who owns the file.
g – Group that owns the file.
o – Other.
a – All.
r – Read the file.
w – Write or edit the file.
x – Execute or run the file as a program.

EXAMPLES:

1. To view your files with what permission they are:

ls -alt

This command is used to view your files with what permission they are.
2. To make a file readable and writable by the group and others.

chmod 066 file1.txt

3. To allow everyone to read, write, and execute the file

chmod 777 file1.txt

passwd command

12.05.2009

13>passwd command

SUMMARY:

Allows you to change your password.

SYNTAX:

-r      Specifies the repository to which an operation is applied. The supported repositories are files, nis or nisplus.
-a     Show password attributes for all entries. Use only with the -s option; name must not be provided. For the nisplus repository, this will show only the entries in the NIS+ password table in the local domain that the invoker is authorized to “read”. For the files repository, this is restricted to the superuser.
-d     Deletes password for name. The login name will not be prompted for password. It is only applicable to the files repository.
-l     Locks password entry for name.
-e     Change the login shell. For the files repository, this only works for the super-user. Normal users may change the nis or nisplus repositories. The choice of shell is limited by the requirements of getusershell(3C). If the user currently has a shell that is not allowed by getusershell , only root may change it.
-f     Force the user to change password at the next login by expiring the password for name.

EXAMPLES:

passwd  – entering just passwd would allow you to change the password. After entering passwd you will receive the following three prompts:

Current Password:
New Password:
Confirm New Password:

Each of these prompts must be entered and entered correctly for the password to be successfully changed.

wc command

04.05.2009

12>wc command

SUMMERY:

The wc (word count) command is a very simple utility found in all Unix variants. Its purpose is counting the number of lines, words and characters of text files. If multiple files are specified, wc produces a count for each file, plus totals for all files.

When used without options wc prints the number of lines, words and characters, in that order. A word is a sequence of one or more characters delimited by whitespace. If we want fewer than the three counts, we use options to select what is to be printed: -l to print lines, -w to print words and -c to print characters. The GNU version of wc found in Linux systems also supports the long options format: –chars (or –bytes), –words, –lines.

SYNTAX:

wc [-c | -m | -C ] [-l] [-w] [ file … ]
-c     Count bytes.
-m     Count characters.
-C     Same as -m.
-l     Count lines.
-w     Count words delimited by white space characters or new line characters. Delimiting characters are Extended Unix Code (EUC) characters from any code set defined by iswspace()
file     Name of file to word count.

EXAMPLES:

If we want to count how many words are in line 70 of file foo.txt then we use:

head -70 foo.txt | tail -1 | wc -w

Here, the command head -70 outputs the first 70 lines of the file, the command tail -1 (i.e., the number 1) outputs the last line of its input, which happens to be line 70 of foo.txt, and wc counts how many words are in that line.

wget command

01.04.2009

11>wget command

SUMMERY:

There are many ways to download files. But there is only one smart way to download from the command line – wget. The wget tool is a non-interactive network download tool that can download single files, recursively download entire directories, and even follow links.
SYNTAX:

-V
–version
Display the version of Wget.
-h
–help
Print a help message describing all of Wget’s command-line options.
-b
–background
Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log.
-e command
–execute command
Execute command as if it were a part of .wgetrc. A command thus invoked will be executed after the commands in .wgetrc, thus taking precedence over them.

EXAMPLES:

Download a single file using wget

$ wget http://www.cyberciti.biz/here/lsst.tar.gz
$ wget ftp://ftp.freebsd.org/pub/sys.tar.gz

Download multiple files on command line using wget

://ftp.redhat.com/pub/xyz-1rc-i386.rpmOR

i) Create variable that holds all urls and later use ‘BASH for loop’ to download all files:
$ URLS=”http://www.cyberciti.biz/download/lsst.tar.gz ftp://ftp.freebsd.org/pub/sys.tar.gz ftp://ftp.redhat.com/pub/xyz-1rc-i386.rpm http://xyz.com/abc.iso" ii) Use for loop as follows:
$ for u in $URLS; do wget $u; doneiii) However, a better way is to put all urls in text file and use -i option to wget to download all files:

(a) Create text file using vi
$ vi /tmp/download.txtAdd list of urls:
http://www.cyberciti.biz/download/lsst.tar.gz
ftp://ftp.freebsd.org/pub/sys.tar.gz
ftp://ftp.redhat.com/pub/xyz-1rc-i386.rpm
http://xyz.com/abc.iso
(b) Run wget as follows:
$ wget -i /tmp/download.txt(c) Force wget to resume download
You can use -c option to wget. This is useful when you want to finish up a download started by a previous instance of wget and the net connection was lost. In such case you can add -c option as follows:
$ wget -c http://www.cyberciti.biz/download/lsst.tar.gz
$ wget -c -i /tmp/download.txt
Please note that all ftp/http server does not supports the download resume feature.

Force wget to download all files in background, and log the activity in a file:

$ wget -cb -o /tmp/download.log -i /tmp/download.txtOR$ nohup wget -c -o /tmp/download.log -i /tmp/download.txt &nohup runs the given COMMAND (in this example wget) with hangup signals ignored, so that the command can continue running in the background after you log out.

See man page of wget for more advanced options.

ONE COMMAND A DAY

29.04.2009

10> yum command.

SUMMERY:

yum-yellowdog updater modified. yum is an interactive, automated update program which can be used for maintaining systems using rpm.

SYNTAX:

install
Is used to install the latest version of a package or group of packages while ensuring that all dependencies are satisfied. If no package matches the given package name(s), they are assumed to be a shell glob and any matches are then installed.
update
If run without any packages, update will update every currently installed package. If one or more packages are specified, Yum will only update the listed packages. While updating packages, yum will ensure that all dependencies are satisfied. If no package matches the given package name(s), they are assumed to be a shell glob and any matches are then installed.If the –obsoletes flag is present yum will include package obsoletes in its calculations – this makes it better for distro-version changes, for example: upgrading from somelinux 8.0 to somelinux 9.

check-update
Implemented so you could know if your machine had any updates that needed to be applied without running it interactively. Returns exit value of 100 if there are packages available for an update. Also returns a list of the pkgs to be updated in list format. Returns 0 and no packages are available for update.
upgrade
Is the same as the update command with the –obsoletes flag set. See update for more details.
remove or erase
Are used to remove the specified packages from the system as well as removing any packages which depend on the package being removed.
list
Is used to list various information about available packages; more complete details are available in the List Options section below.
provides or whatprovides
Is used to find out which package provides some feature or file. Just use a specific name or a file-glob-syntax wildcards to list the packages available or installed that provide that feature or file.
search
Is used to find any packages matching a string in the description, summary, packager and package name fields of an rpm. Useful for finding a package you do not know by name but know by some word related to it.
info
Is used to list a description and summary information about available packages; takes the same arguments as in the List Options section below.
clean
Is used to clean up various things which accumulate in the yum cache directory over time. More complete details can be found in the Clean Options section below.
shell
Is used to enter the ‘yum shell’, when a filename is specified the contents of that file is executed in yum shell mode. See yum-shell(8) for more info
resolvedep
Is used to list packages providing the specified dependencies, at most one package is listed per dependency.
localinstall
Is used to install a set of local rpm files. If required the enabled repositories will be used to resolve dependencies.
localupdate
Is used to update the system by specifying local rpm files. Only the specified rpm files of which an older version is already installed will be installed, the remaining specified packages will be ignored. If required the enabled repositories will be used to resolve dependencies.
deplist
Produces a list of all dependencies and what packages provide those dependencies for the given packages.

General Options

Most command line options can be set using the configuration file as
well and the descriptions indicate the necessary configuration option to set.
-h, –help
Help; display a help message and then quit.
-y
Assume yes; assume that the answer to any question which would be asked is yes.
Configuration Option: assume-yes
-c [config file]
Specifies the config file location – can take http, ftp urls and local file paths.
-d [number]
Sets the debugging level to [number] – turns up or down the amount of things that are printed. Practical range: 0 – 10
Configuration Option: debuglevel
-e [number]
Sets the error level to [number] Practical range 0 – 10. 0 means print only critical errors about which you must be told. 1 means print all errors, even ones that are not overly important. 1+ means print more errors (if any) -e 0 is good for cron jobs.
Configuration Option: errorlevel
-R [time in minutes]
Sets the maximum amount of time yum will wait before performing a command – it randomizes over the time.
-C
Tells yum to run entirely from cache – does not download or update any headers unless it has to to perform the requested action.
–version
Reports the yum version number and exits.
–installroot=root
Specifies an alternative installroot, relative to which all packages will be installed.
Configuration Option: installroot
–enablerepo=repoidglob
Enables specific repositories by id or glob that have been disabled in the configuration file using the enabled=0 option.
Configuration Option: enabled
–disablerepo=repoidglob
Disables specific repositories by id or glob.
Configuration Option: enabled
–obsoletes
This option only has affect for an update, it enables yum‘s obsoletes processing logic. For more information see the update command above.
Configuration Option: obsoletes
–exclude=package
Exclude a specific package by name or glob from updates on all repositories.
Configuration Option: exclude
–noplugins
Run with all plugins disabled.
Configuration Option: plugins

List Options

The following are the ways which you can invoke yum in list mode. Note that all list commands include information on the version of the package.

yum list [all | glob_exp1] [glob_exp2] […]
List all available and installed packages.
yum list available [glob_exp1] […]
List all packages in the yum repositories available to be installed.
yum list updates [glob_exp1] […]
List all packages with updates available in the yum repositories.
yum list installed [glob_exp1] […]
List the packages specified by args. If an argument does not match the name of an available package, it is assumed to be a shell-style glob and any matches are printed.
yum list extras [glob_exp1] […]
List the packages installed on the system that are not available in any yum repository listed in the config file.
yum list obsoletes [glob_exp1] […]
List the packages installed on the system that are obsoleted by packages in any yum repository listed in the config file.
yum list recent
List packages recently added into the repositories.
Specifying package names
All the list options mentioned above take file-glob-syntax wildcards or package names as arguments, for example yum list available ‘foo*’ will list all available packages that match ‘foo*’. (The single quotes will keep your shell from expanding the globs.)

Clean Options

The following are the ways which you can invoke yum in clean
mode. Note that “all files” in the commands below means “all files in currently enabled repositories”. If you want to also clean any (temporarily) disabled repositories you need to use –enablerepo=’*’ option.
yum clean packages
Eliminate any cached packages from the system. Note that packages are not automatically deleted after they are downloaded.
yum clean headers
Eliminate all of the header files which yum uses for dependency resolution.
yum clean metadata
Eliminate all of the files which yum uses to determine the remote availability of packages. Using this option will force yum to download all the metadata the next time it is run.
yum clean dbcache
Eliminate the sqlite cache used for faster access to metadata. Using this option will force yum to recreate the cache the next time it is run.
yum clean all
Runs yum clean packages and yum clean headers as above.

EXAMPLES:

yum install packagename——–>       yum install openarena
yum whatprovides filename
yum remove appname
yum update.


ONE COMMAND A DAY

28.04.2009

9>rm command.

SUMMERY:
rm linux command is used to remove/delete the file from the directory.

SYNTAX:
The Syntax is
rm [options..] [file | directory]

OPTIONS:

-f     Remove all files in a directory without prompting the user.
-i     Interactive. With this option, rm prompts for confirmation before removing any files.
-r (or) -R     Recursively remove directories and subdirectories in the argument list. The directory will be emptied of files and removed. The user is normally prompted for removal of any write-protected files which the directory contains.

EXAMPLES:
1. To Remove / Delete a file:

rm file1.txt

Here rm command will remove/delete the file file1.txt.
2. To delete a directory tree:

rm -ir tmp

This rm command recursively removes the contents of all subdirectories of the tmp directory, prompting you regarding the removal of each file, and then removes the tmp directory itself.
3. To remove more files at once

rm file1.txt file2.txt

rm command removes file1.txt and file2.txt files at the same time.

ONE COMMAND A DAY

27.04.2009

8> mv command.

SUMMERY:

The Linux command ‘mv‘ can be use to rename files or to rename directory in Linux system. The ‘mv‘ command also can be use to moving the files or to moving directory to different directory. The ‘mv‘ command can be interpret as copying and then deleting the files or directory but this is done in much faster paste than manually copying and then deleting the files or folder.

SYNTAX:

mv [-f] [-i] oldname newname

-f mv will move the file(s) without prompting even if it is writing over an existing target. Note that this is the default if the standard input is not a terminal.
-i Prompts before overwriting another file.
oldname The oldname of the file renaming.
newname The newname of the file renaming.
filename The name of the file you want to move directory – The directory of were you want the file to go.

Examples

mv myfile.txt newdirectory/ – moves the file myfile.txt to the directory newdirectory.

mv myfile.txt ../ – moves the file myfile.txt back one directory (if available).