Linux Commands - IT magazine

IT magazine

Knowledge that matters

Linux Commands

Share This


Linux Commands
arch:
Displays the architecture of the machine on which Linux is running. For instance, i586 represents a Pentium-based system, i486represents an 80486-based computer, and axp represents Linux running on an Alpha-based computer.
          Syntax :- arch



at:
Schedules commands to be executed at a specific time. User is prompted for the commands, or the commands can be provided from a file. Each job is added to a schedule queue and is provided a job number.
Syntax:at [-f filename] [-l] [-m] [-d job [job ...]] TIME
Flags & Options:
·         -d job: Deletes a job specified by job number.
  • -f filename: Reads commands to be scheduled from the specified file rather than prompting for the commands.
  • -l: Displays commands in the schedule queue (the TIME argument is ignored).
  • -m: E-mails the user who scheduled the job once the job is finished and includes any generated output in the body of the message.
Notes : Specifying times: Several options exist for specifying time, including these:
  • HH:MM specifies the hour and minutes, such as 11:15 or 22:30. AM and PM suffixes are allowed, as in 11:15AM or 11:30PM.
  • midnight (24:00 or 12:00PM), noon (12:00), and teatime (16:00) are reserved words specifying the times indicated.
  • MMDDYY, MM/DD/YY, or DD.MM.YY can be used to indicate specific dates, as in 022598 or 25.02.98.
  • now specifies the current time.
  • tomorrow specifies the next day.
  • Using a + can specify offsets in minutes, hours, days, or weeks from a specified time. For instance, to schedule a command for noon two days from the current day, you could use noon + 2 days.
atd :
Daemon that runs jobs scheduled for later execution by programs such as at and batch.
          Syntax: atd [-l load] [-b interval]
Flags and Options:
o    -b interval: Indicates the minimum interval in seconds between the start of two batch jobs. By default, this is 60 seconds.
o    -l load: Specifies a load limit over which scheduled batch jobs will not be run. By default, this load is 0.8.

atq:
Displays jobs scheduled by atthat are in the schedule queue. This is the same as at -l.
Syntax: atq
atrm:
Removes specified jobs from the atschedule queue. This is the same as at -d.
Syntax:  atrm job [job ...]
badblocks:
Checks a device (usually a hard disk) for bad blocks.
Syntax: badblocks [-o filename] [-w] device blocks-count
Flags and Options:   
o    -o filename: Specifies a file where results should be written instead of displaying them on the standard output.
o    -w: Uses a write test, instead of a read-only test, in which data is written to each block of the device and then reread from the block.
Notes:
You should specify the device using the full Linux device path, such as /dev/hda2or /dev/sdb3. The number of blocks on the device is essential (this information can be determined using fdisk).
Warnings:
Do not use the -w flag on devices that contain important data. Data stored on devices that are checked with the -wflag will get erased during the checking process.
batch:
Schedules commands to be executed at a specified time as long as system load levels permit. User is prompted for the commands, or the commands can be provided from a file. Each job is added to a schedule queue and is provided a job number.
Syntax:  batch [-f filename] [-m] TIME
Flags and Options:
o    -f filename: Reads commands to be scheduled from the specified file rather than prompting for the commands.
o    -m: E-mails the user who scheduled the job once the job is finished and includes any generated output in the body of the message.
Notes: 
Specifying times: Several options exist for specifying time, including these:
o    HH:MM specifies the hour and minutes, such as 11:15 or 22:30. AM and PM suffixes are allowed, as in 11:15AM or 11:30PM.
o    midnight (24:00 or 12:00PM), noon (12:00), and teatime (16:00) are reserved words specifying the times indicated.
o    MMDDYY, MM/DD/YY, or DD.MM.YYcan be used to indicate specific dates, as in 022598 or 25.02.98.
o    now specifies the current time.
o    tomorrow specifies the next day.
o    Using a +can specify offsets in minutes, hours, days, or weeks from a specified time. For instance, to schedule a command for noon two days from the current day, you could use noon + 2 days.

bc:
An interactive, arbitrary-precision calculator. Processes all expressions in specified files as well as prompting user to provide expressions for evaluation.
Syntax: bc [file ...]
Notes: The syntax of expressions used by bc is largely based on the C programming language. Refer to the bc man page for details.
Expressions in files provided as arguments are processed before presenting a prompt to the user for entering additional expressions to be processed.
biff:
Notifies users when new mail arrives and indicates who sent the message.
Syntax: biff  [ny]
Flags and Options:
o    n: Disables mail arrival notification when it is enabled.
o    y: Enables mail arrival notification when it is disabled.
cal:
Displays a calendar for a month or an entire year. If no month or year is specified, the current month’s calendar is displayed.
Syntax: cal [-j] [-y] [month [year]]
Flags and Options:
o    -j: Specifies that Julian dates instead of Gregorian dates should be used.
o    -y: Displays a yearly calendar instead of a monthly calendar.
Notes:
A single numeric argument specifies a year between the year 1 and the year 9999 (years must be complete—e.g., 1998, not 98). With two arguments, the first specifies the month numerically from 1 to 12 and the second the year from 1 to 9999.
cat:
cat [-benstvAET] [--number] [--number-nonblank] [--squeeze-blank] [--show-nonprinting] [--show-ends] [--show-tabs] [--show-all] [file..]
Flags and Options:
o    -A/--show-all: Displays a $at the end of each line, tab characters as ^I, and control characters preceded by a ^. This is the same as the combination of -v, -T, and -E.
o    -b/--number-nonblank: Causes all non-blank lines to appear numbered. Numbering starts at 1.
o    -e: Displays a $at the end of each line and control characters preceded by a ^. This is the same as the combination of -v and -E.
o    -E/--show-ends: Displays a $at the end of each line.
o    -n/--number: Causes all lines to appear numbered. Numbering starts at 1.
o    -s/--squeeze-blank: Replaces sequences of multiple blank lines with single blank lines when displayed.
o    -t: Displays tab characters as ^I and control characters preceded by a ^. This is the same as the combination of -v and -T.
o    -T/--show-tabs: Displays tab characters as ^I.
o    -v/--show-nonprinting: Displays control characters preceded by a ^.
checkalias:
Checks the user’s file and then the system alias file in order to see if a specified alias is defined.
Syntax: checkalias alias[, alias,...]
chgrp:
Changes the group ownership of one or more files or directories.
Syntax: chgrp [-Rcfv] [--recursive] [--changes] [--silent] [--quiet] [--verbose] group file ...
Flags & Options:
o    -c/--changes: Displays the names of only those files whose ownership is being changed.
o    -f/--silent/--quiet: Suppresses display of error messages when a file’s ownership cannot be changed.
o    -R/--recursive: Recursively changes the ownership of all files in all subdirectories of any directory that has its ownership changed.
o    -v/--verbose: Displays the results of all ownership changes.
Notes: The group can be specified either by name or by group ID.
chkconfig: Manipulates or displays settings for system run levels.
Syntax:
chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name <on|off|reset>
chkconfig [--level levels] name
Flags & Options:
o    --add name: Adds a new service for management by chkconfig and checks that the necessary start and kill entries exist. If entries are missing, they are created.
o    --del name: Deletes the named service from management; any links to it are also deleted.
o    --level[levels: Specifies numerically which run level a named service should belong to.
o    --list name: Lists all services that chkconfig knows about and any relevant information about them. If a named service is specified, only information about that service is displayed.
o    off: When specified after the service name, the service’s status for the specified run level is changed to a stopped state. If no run level is specified, then this option affects run levels 3, 4, and 5.
o    on: When specified after the service name, the service’s status for the specified run level is changed to a started state. If no run level is specified, then this option affects run levels 3, 4, and 5.
o    reset: When specified after the service name, the service’s status for the specified run level is set to the default status indicated by the initscript. If no run level is specified, then this option affects all run levels.

chomod:
Changes the access permissions of one or more files or directories.
Syntax:
chmod [-Rcfv] [--recursive] [--changes] [--silent] [--quiet] [--verbose] mode file ...
Flags & Options:
o    -c/--changes: Displays the names of only those files whose permissions are being changed.
o    -f/--silent/--quiet: Suppresses display of error messages when a file’s permissions cannot be changed.
o    -R/--recursive: Recursively changes the permissions of all files in all subdirectories of any directory that has its permissions changed.
o    -v/--verbose: Displays the results of all permission changes.

Notes: Modes can be specified in two ways: symbolically and numerically. When done symbolically, modes take the form [ugoa][[+-=][rwxXstugo ...]. The first element ([ugoa]) represents the users whose permissions are being affected (u=user who owns the file or directory, g=all members of the group that owns the file or directory, o=anyone who is not the owner or in the owner group, a=all users). The + symbol means that the specified modes should be added to already specified permissions, the - symbol means the specified modes should be removed from existing permissions, and the = means that the specified modes should replace existing permissions. There are many different permissions that can be specified in the third element of the mode, including r for read permissions, w for write permissions, and x for execute permissions.
Full details of symbolic and numeric modes appear in the chmod man page.
chown:
Changes the user and/or group ownership of one or more files or directories.
Syntax: chown [-Rcfv] [--recursive] [--changes] [--silent] [--quiet] [--verbose] [user][:.][group] file ...
Flags & Options:
o    -c/--changes: Displays the names of only those files whose ownership is being changed.
o    -f/--silent/--quiet: Suppresses display of error messages when a file’s ownership cannot be changed.
o    -R/--recursive: Recursively changes the ownership of all files in all subdirectories of any directory that has its ownership changed.
o    -v/--verbose: Displays the results of all ownership changes.
Notes:
o    The user and group can be specified either by name or by IDs. User and group can be combined in several ways:
o    The user followed by a dot or colon followed by a group changes both the user and group ownerships to those specified.
o    The user followed by a dot or colon and no group changes the user ownership as specified and changes the group ownership to the specified user’s login group.
o    If the colon or dot and group are specified without a user, then only group ownership is changed. This is the same as chgrp.
o    If the user is not followed by a dot or colon, then only the user ownership is changed.

clear:
Clears the terminal screen and resets the prompt and cursor location to the first line of the screen.
Syntax: clear
compress:
Compresses files or the standard input using Lempel-Ziv compression.
Syntax: compress [-f] [-v] [-c] [-r] [file ...]
Flags & Options:
o    -c: Returns compressed data on standard output rather than to a file as is the default when compressing a file.
o    -f: Forces compression of hard-linked files, which are ignored by default.
o    -r: Operates recursively. If a directory is specified as an argument, then compresses all files within that directory and in its subdirectories.
o    -v: Displays the percentage reduction in size for each file compressed.
Notes: When compressing files, compressreplaces the original file with a file whose name has a .Zprefix but otherwise remains unchanged. This behavior is overridden by the -cflag. If no files are specified, the standard input is compressed and the results are returned through standard output.
cp:
Copies files and directories.
Syntax:
cp [-a] [--archive] [-b] [--backup] [-d] [--no-dereference] [-f] [--force] [-i] [--interactive] [l] [--link] [-p] [--preserve] [-R] [--recursive] [-s] [--symbolic-link] [-u] [--update] source destination
cp [options] source ... directory
Flags & Options:
o    -a/--archive: Copies files and directories recursively, maintaining symbolic links as links and preserving ownership and permissions of the original files. This is the same as -dpR.
o    -b/--backup: Makes backup copies of files before the original files are overwritten.
o    -d/--no-dereference: Copies links as links rather than copying the files to which the links point.
o    -f/--force: Forces removal of existing destination files that need to be overwritten.
o    -i/--interactive: Prompts before overwriting existing destination files.
o    -l/--link: Makes hard links instead of copying files. This applies only to files, not to directories.
o    -p/--preserve: Preserves the ownership and permissions of the original files.
o    -R/--recursive: Recursively copies directories. That is, for every source directory specified, every file in the directory and all its subdirectories are copied while retaining the matching directory structure.
o    -s/--symbolic-link: Makes symbolic links instead of copying files. Source files must be specified with full paths.
o    -u/--update: Replaces only those destination files that have older modification times than the corresponding source files.

Warnings: Care needs to be taken with the -fflag when working as the root user. Making a mistake can cause important system files to be overwritten because the root user generally has write permission for all files and directories.
crontab:
Displays or alters a user’s Cron table (crontab). The Cron table specifies scheduled actions that are executed by the Cron daemon.
Syntax:
crontab [-u user] file
crontab [-u user] { -l|-r| -e }
Flags & Options:
o    -e: Edits the crontab file of the user executing the command or the user specified by the -uflag. The editor invoked is specified by the EDITOR environment variable.
o    -l: Displays the contents of the crontab file of the user executing the command or the user specified by the -u flag.
o    -r: Deletes the crontab file of the user executing the command or the user specified by the -uflag.
o    -u: Specifies which user’s crontab file to work with if it is not the same user as the one executing the command. This flag can only be used by the root user.

Notes:
The format of entries in crontabfiles is discussed in Chapter 14, "General System Administration."
cryptdir:
Encrypts all files in a specified directory. If no directory is specified, then all files in the current directory are encrypted.
Syntax: cryptdir [dir]
Notes: When encrypting files, you will be prompted twice for a password. This password is needed to unencrypt files. Encrypted files will have the .crypt extensions added to their names. Use decryptdir to decrypt the files.
date:
Displays or sets the current system date and time.
Syntax: date [-u] [--universal] [MMDDhhmm[[CC]YY][.ss]]
Flags & Options:
o    -u/--universal: Displays the time in Greenwich Mean Time (also known as Coordinated Universal Time).
Notes:
If a date and time are provided as an argument, this is done entirely with numbers where the two-digit elements shown above represent the following values:
o    MM: month
o    DD: day of the month
o    hh: hour
o    mm: minute
o    CC: century (first two digits of the year)
o    YY: last two digits of the year
o    ss: seconds
Keep in mind that only the root user can set the system clock.
dc:
An interactive, arbitrary-precision, reverse-polish notation calculator. Processes all expressions in specified files as well as prompting user to provide expressions for evaluation.
Syntax: dc [file ...]
Notes:
Detailed syntax of expressions used by dcis documented in the dc man page. Expressions in files provided as arguments are processed before presenting a prompt to the user for entering additional expressions to be processed.
decryptdir:
Decrypts all files in a specified directory. If no directory is specified, then all files in the current directory are encrypted. Files must have been encrypted with the encryptdir command.
Syntax: cryptdir [dir]
Notes: You will be prompted for a password when decrypting files. You need to provide the same password used when encrypting the files, or the process will fail.
depmod:
Returns module dependencies on the standard output. These can be stored in a file and then used by modprobefor installing loadable modules.
Syntax: depmod module1.o module2.o ...
df:
Displays free space on one or more mounted disks or partitions. If no files (or directories) are specified, then the free space on all mounted file systems is displayed. If filenames are specified, then the free space for the file system containing each file is displayed.
Syntax: df [-T] [-t fstype] [-x fstype] [--all] [--inodes] [--type=fstype] [--exclude-type=fstype] [--print-type] [filename ...]
Flags & Options:
o    -t/--type=fstype: Displays information only for file systems of the specified type.
o    -T/--print-type: Displays the file system type for each file system reported.
o    -x/--exclude-type=fstype: Does not report information for file systems of the specified type.

dir:
Displays a listing of the files in a specified directory, in alphabetical order unless otherwise specified. By default, displays the contents of the current directory unless another directory is specified.
Syntax: dir [-acCGlnrRStuU] [--all] [--no-group] [--numeric-uid-gid] [--reverse] [--recursive] [file ...]
Flags & options:
o    -a/--all: Shows all entries, including those whose names start with ..
o    -c: Sorts by the creation time of the file and, when displaying complete file information (with the -l flag), displays the creation time.
o    -C: Displays entries in columns.
o    -G/--no-group: Prevents display of group information.
o    -l: Displays files with long listing format.
o    -n/--numeric-uid-gid: Lists user IDs and group IDs (UIDs and GIDs)– instead of names.
o    -r/--reverse: Reverses order of entries when sorting.
o    -R/--recursive: Recursively lists contents of subdirectories.
o    -S: Sorts files by size.
o    -t: Sorts by the modification time of the file and, when displaying complete file information (with the -l flag), displays the modification time.
o    -u: Sorts by the last access time of the file and, when displaying complete file information (with the -l flag), displays the last access time.
o    -U: Displays entries in their directory order rather than sorted.
dmseg:
Displays or manipulates the kernel ring buffer. This is where many bootup messages are kept.
Syntax: dmesg [-c]
Flags & Options:
o    -c: Clears the ring buffer after displaying the contents.

dnsdomainname:
Displays the system’s DNS domain name based on its fully qualified domain name.
Syntax: domainname
du:
Displays a report of disk space usage for each specified file or directory as well as all subdirectories of specified directories. By default, displays information for all files and directories in the current directory.
Syntax: du [-abcksx] [--all] [--bytes] [--total] [--kilobytes] [--summarize] [--one-file-system] [file ...]
Flags & Options:
o    -a/--all: Displays usage information for files and directories.
o    -b/--bytes: Displays usage information in bytes.
o    -c/--total: Displays a total usage figure for all.
o    -k/--kilobytes: Displays usage information in kilobytes.
o    -s/--summarize: Displays a total for each argument and does not display individual information for each file or subdirectory inside a directory.
o    -x/--one-file-system: Skips directories that are not part of the current file system.
e2fsck:
Checks the state of a Linux second extended file system. This is the default file system used for Linux partitions.
Syntax: e2fsck [-cfnpy] [-B blocksize] device
Flags & Options:
o    -B blocksize: Specifies a specific block size to use in searching for the superblock. By default, the program will search at various different block sizes until it finds the superblock.
o    -c: Causes the badblocks program to be run and marks any bad blocks accordingly.
o    -f: Forces checking of file systems that outwardly seem clean.
o    -n: Opens the file system in a read-only state and answers "no" to all prompts to take action.
o    -p: Forces automatic repairing without prompts.
o    -y: Assumes an answer of "yes" to all questions.
Notes:
The device to be checked should be specified using the complete Linux device path, such as /dev/hda1or /dev/sdb3. It is advisable that the file system not be mounted or, if you need to check the root file system or a file system that must be mounted, that this be done in single-user mode.
echo:
Displays a line of text, optionally without a trailing new line (a new line is included by default).
Syntax: echo [-ne] [string ...]
Flags & Options:
o    -e: Enables interpretation of backslashed special characters in the string.
o    -n: Disables output of a trailing new line.
Notes:
Backslashed special characters include:
o    \b: backspace
o    \f: form feed
o    \n: new line
o    \r: carriage return
o    \t: horizontal tab
o    \\: backslash

egrep:
Searches files for lines matching a specified pattern and displays the lines. The pattern is interpreted as an extended regular expression.
Syntax:
egrep [-bCciLlnvwx] [-number] [-e pattern] [-f file] [--byte-offset] [--context] [--count] [--regexp=pattern] [--file=file] [--ignore=case] [--files-without-match] [--files-with-match] [--line-number] [--revert-match] [--word-regexp] [--line-regexp] [pattern] file [file ...]
Flags & Options:
o    -number: Displays matching lines with the specified number of lines of leading and trailing context.
o    -b/--byte-offset: Prints the byte offset of the match before each line.
o    -c/--count: Instead of displaying matching lines, simply outputs a count of the total number of lines matching the expressions (when combined with -v, displays the total count of non-matching lines).
o    -C/--context: Displays matching lines with two lines of leading and trailing context (this is the same as -2).
o    -e pattern/--regexp=pattern: Uses the specified regular expression rather than one provided as an argument.
o    -f file/--file=file: Uses the regular expression found in the specified file rather than one supplied as an argument.
o    -i/--ignore-case: Ignores case in both the pattern and the files being searched.
o    -l/--files-with-matches: Instead of displaying each matched line, simply displays the name of each file that contains at least one match for the regular expression.
o    -L/--files-without-match: Instead of displaying each matched line, simply displays the name of each file that contains no matches for the regular expressions.
o    -n/--line-number: Prefixes each output line with its line number in the file.
o    -v/--revert-match: Displays non-matching lines instead of matching lines.
o    -w/-word-regexp: Displays only those lines with matches for the regular expression that are complete words.
o    -x/--line-regexp: Displays only those lines with matches for the regular expression that are complete lines.
Notes: The syntax of regular expressions used by egrep can be found in the egrep man page.
false:
Does nothing and returns a failure exit status.
Syntax: false
fdisk:
Provides tools for manipulating partition tables. By default, fdisk starts ready to work with the current device unless a different device is specified as an argument.
Syntax: fdisk [-l] [-s partition] [device]
Flags & Options:
o    -l: Lists the partition tables for /dev/hda, /dev/hdb, and /dev/sdathrough /dev/sdhand then exits.
o    -s partition: Returns the size of the specified partition on the standard output and exits.
fgrep:
Searches files for lines matching a specified pattern and displays the lines. The pattern is interpreted as a list of fixed strings as opposed to regular expressions. Strings are separated by new lines and any of the strings can be matched.
Syntax:
fgrep [-bCciLlnvwx] [-number] [-e pattern] [-f file] [--byte-offset] [--context] [--count] [--regexp=pattern] [--file=file] [--ignore=case] [--files-without-match] [--files-with-match] [--line-number] [--revert-match] [--word-regexp] [--line-regexp] [pattern] file [file ...]
Flags & Options:
o    -number: Displays matching lines with the specified number of lines of leading and trailing context.
o    -b/--byte-offset: Prints the byte offset of the match before each line.
o    -c/--count: Instead of displaying matching lines, simply outputs a count of the total number of lines matching the expressions (when combined with -v, displays the total count of non-matching lines).
o    -C/--context: Displays matching lines with two lines of leading and trailing context (this is the same as -2).
o    -e pattern/--regexp=pattern: Uses the specified pattern rather than one provided as an argument.
o    -f file/--file=file: Uses the pattern found in the specified file rather than one supplied as an argument.
o    -i/--ignore-case: Ignores case in both the pattern and the files being searched.
o    -l/--files-with-matches: Instead of displaying each matched line, simply displays the name of each file that contains at least one match for the pattern.
o    -L/--files-without-match: Instead of displaying each matched line, simply displays the name of each file that contains no matches for the pattern.
o    -n/--line-number: Prefixes each output line with its line number in the file.
o    -v/--revert-match: Displays non-matching lines instead of matching lines.
o    -w/-word-regexp: Displays only those lines with matches for the pattern that are complete words.
o    -x/--line-regexp: Displays only those lines with matches for the pattern that are complete lines.

file:
Determines and displays the type of files.
Syntax: file [-zL] [-f file] file ...
Flags & Options:
o    -f file: Reads the list of files to be checked from the specified file. These will be checked before checking files provided as arguments.
o    -L: Causes symbolic links to be followed.
o    -z: Attempts to look at the type of files inside compressed files.
find:
Looks for files below the specified paths that match all the criteria indicated by the options and takes any action indicated by the options. If no paths are specified, the search takes place below the current directory.
Syntax: find [path ...] [options]
Flags & Options:
o    -amin minutes: Looks for files last accessed the specified number of minutes ago.
o    -anewer file: Looks for files that were accessed more recently than the specified file was modified.
o    -atime days: Looks for files last accessed the specified number of 24-hour periods ago.
o    -cmin minutes: Looks for files whose status was last changed the specified number of minutes ago.
o    -cnewer file: Looks for files whose status was last changed more recently than the specified file was modified.
o    -ctime days: Looks for files whose status was changed the specified number of 24-hour periods ago.
o    -empty: Looks for empty files or directories.
o    -exec command \;: Executes the specified command. The string {}is replaced by the currently found file name and the command is repeated for each found filename.
o    -gid gid: Looks for files with the specified numeric GID.
o    -group group: Looks for files belonging to the named group.
o    -ilname pattern: Looks for symbolic links whose names match the specified pattern in a case-insensitive manner.
o    -iname pattern: Looks for files whose names match the specified pattern in a case-insensitive manner.
o    -ipath pattern: Looks for files whose path matches the specified pattern in a case-insensitive manner.
o    -lname pattern: Looks for symbolic links whose names match the specified pattern in a case-sensitive manner.
o    -maxdepth levels: Descends at most the specified numbers of levels below the specified paths.
o    -mindepth levels: Descends at least the specified number of levels below the specified paths before starting testing.
o    -mmin minutes: Looks for files that were last modified the specified number of minutes ago.
o    -mount: Does not descend any directories that are on other file systems than the current one.
o    -mtime days: Looks for files that were last modified the specified number of 24-hour periods previously.
o    -name pattern: Looks for files whose names match the specified pattern in a case-sensitive manner.
o    -newer file: Looks for files modified more recently than the specified file.
o    -nogroup: Looks for files whose numeric GID does not correspond to any existing group.
o    -nouser: Looks for files whose numeric UID does not correspond to any existing user.
o    -ok command \;: Executes the specified command for each file found after prompting the user. The string {} is replaced by the currently replaced filename.
o    -path: Looks for files whose path matches the specified pattern in a case-sensitive manner.
o    -perm mode: Looks for files whose permissions exactly match the specified mode. If +modeis used, then matches any of the specified permission bits; if -modeis used, then matches all of the specified permission bits.
o    -print: Prints the full filename of all found files.
o    -regex pattern: Looks for files whose names match the specified regular expression.
o    -size size[bckw]: Looks for files of the specified size in the specified units. Units include b(512-byte blocks), c (bytes), k (kilobytes), and w(2-byte words).
o    -type type: Looks for files that match the specified type. Types include d(directories), f (regular files), and l (symbolic links).
o    -uid uid: Looks for files with the specified UID.
o    -user username: Looks for files owned by the specified username or UID.
Notes:
When providing numeric time information such as minutes and days, normally the match must be exact. Preceding the number with a + matches any value greater than the specified number and preceding a value with a -matches any value less than the number.
finger:
Looks up specified information about a user on the local system or remote systems. Users are specified on local systems by their username or their first or last name and on remote systems as username@host. With no users specified for the local system, all users logged in to the current system are listed. If a host with no username is provided in the form @host, then a list of all users logged into the remote system is displayed.
Syntax: finger [user ...]
free:
Displays a report of free and used memory.
Syntax: free [-b|-k|-m] [-s delay] [-t]
Flags & Options:
o    -b: Displays the amount of memory in bytes.
o    -k: Displays the amount of memory in kilobytes (this is the default).
o    -m: Displays the amount of memory in megabytes.
o    -s delay: Displays continued reports separated by the specified delay in seconds.
o    -t: Displays an extra line containing totals.
gpasswd:
Administers the /etc/group file. Without flags, gpasswd allows changing of the specified group’s password.

Syntax:
gpasswd group
gpasswd -a user group
gpasswd -d user group
gpasswd -R group
gpasswd -r group
gpasswd [-M user,...] group
Flags & Options:
o    -a user: Adds a user to the group.
o    -d user: Removes a user from the group.
o    -M user,...: Specifies one or more users who are members of the group.
o    -r: Removes the group password.
o    -R: Disables access to the group through the newgrp command.
grep:
Searches files for lines matching a specified pattern and displays the lines.
Syntax:
grep [-bCcEFGiLlnvwx] [-number] [-e pattern] [-f file] [--basic-regexp] [--extended-regexp] [--fixed-strings] [--byte-offset] [--context] [--count] [--regexp=pattern] [--file=file] [--ignore=case] [--files-without-match] [--files-with-match] [--line-number] [--revert-match] [--word-regexp] [--line-regexp] [pattern] file [file ...]
Flags & Options:
o    -number: Displays matching lines with the specified number of lines of leading and trailing context.
o    -b/--byte-offset: Prints the byte offset of the match before each line.
o    -c/--count: Instead of displaying matching lines, simply outputs a count of the total number of lines matching the expressions (when combined with -v, displays the total count of non-matching lines).
o    -C/--context: Displays matching lines with two lines of leading and trailing context (this is the same as -2).
o    -e pattern/--regexp=pattern: Uses the specified pattern rather than one provided as an argument.
o    -E/--extended-regexp: Treats the pattern as an extended regular expression (similar to egrep).
o    -f file/--file=file: Uses the pattern found in the specified file rather than one supplied as an argument.
o    -F/--fixed-strings: Treats the pattern as a list of new line separated strings, one of which must match. This is the same as fgrep.
o    -G/--basic-regexp: Treats the pattern as a basic regular expression.
o    -i/--ignore-case: Ignores case in both the pattern and the files being searched.
o    -l/--files-with-matches: Instead of displaying each matched line, simply displays the name of each file that contains at least one match for the patterns.
o    -L/--files-without-match: Instead of displaying each matched line, simply displays the name of each file that contains no matches for the patterns.
o    -n/--line-number: Prefixes each output line with its line number in the file.
o    -v/--revert-match: Displays non-matching lines instead of matching lines.
o    -w/-word-regexp: Displays only those lines with matches for the patterns that are complete words.
o    -x/--line-regexp: Displays only those lines with matches for the patterns that are complete lines.
Notes: The syntax of regular expressions used by grep can be found in the grep man page.
groupadd:
Creates a new group.
Syntax: groupadd [-g gid [-o]] [-r] [-f] group
Flags & Options:
o    -f: Prevents the program from exiting when trying to add a group that already exists. In this case, the group won’t be altered.
o    -g gid: Uses the specified GID for the group instead of automatically assigning a value.
o    -o: Indicates that group IDs do not need to be unique.
o    -r: Adds a system account with a group ID lower than 499.
groupdel: deletes a group
groupdel group
groupmod:
Modifies an existing group.
Syntax: groupmod [-g gid [-o]] [-n groupname] group
Flags & Options:     
o    -g gid: Changes the group ID of the specified group to the new GID. This value must be unique unless -ois specified.
o    -n groupname: Changes the group name of the specified group to the new group name.
o    -o: Indicates that group IDs do not need to be unique.
groups:
Prints the groups that one or more users belongs to. If no user is specified, then displays the groups that the user running the command belongs to.
Syntax:
groups [username ...]
grpck:
Checks the integrity of a group file such as /etc/group or /etc/gshadow. If no files are specified, then the default files are checked.
Syntax: grpck [-r] [group shadow]
Flags & Options:
o    -r: Operates in read-only mode, not allowing any alterations to be made to the files.
gunzip:
Decompresses files compressed with the gzipcommand (as well as the compresscommand and the zipcommand).
Syntax:
gunzip [-cflrt] [--stdout] [--to-stdout] [--force] [--list] [--recursive] [--test] [name ...]
Flags & Options:
o    -c/--stdout/--to-stdout: Writes output to standard output, keeping original file unchanged. By default, gunzip replaces the original compressed files with the uncompressed versions of the files.
o    -f/--force: Forces decompression even when a corresponding file already exists and will be overwritten by the decompressed file.
o    -l/--list: Lists files in the compressed file without decompressing.
o    -r/--recursive: Decompresses recursively, descending the directory structure and decompressing all files in subdirectories of directories named on the command line as arguments.
o    -t/--test: Tests the integrity of compressed files.
Gzexe:
Creates an executable compressed file. If you compress a binary file or script with gzexe, then you can run it as if it were uncompressed. The file will simply uncompress into memory and execute, leaving the compressed version on your hard drive.
Syntax: gzexe [-d] [name ...]
Flags & Options:
·         d: Uncompresses the specified file or files rather than compressing them.
Notes: When you compress a file named filename, the original, uncompressed file will be copied to filename~ and the compressed file will retain the name filename. Once you have tested the compressed executable to see that it works, you can then delete the uncompressed copy.
gzip:
Compresses files using Lempel-Ziv encoding. The resulting file generally replaces the original, uncompressed file and will have a .gz extension.
Syntax: gzip [-cdflrt] [--decompress] [--uncompress] [--stdout] [--to-stdout] [--force] [--list] [--recursive] [--test] [name ...]
Flags & Options:
o    -c/--stdout/--to-stdout: Writes output to standard output, keeping original file unchanged. By default, gzip replaces the original, uncompressed files with the compressed versions of the files.
o    -d/--decompress/--uncompress: Decompresses the specified files, like gunzip, rather than compressing them.
o    -f/--force: Forces compression even when a corresponding file already exists and will be overwritten by the compressed file.
o    -l/--list: Lists files in a compressed file.
o    -r/--recursive: Compresses recursively, descending the directory structure and compressing all files in subdirectories of directories named on the command line as arguments.
o    -t/--test: Tests the integrity of compressed files.
halt:
Halts the system. If the system is not in run level 0 or 6, this is done by calling shutdown.
Syntax: halt [-n] [-w] [-d] [-f] [-i]
Flags & Options:
o    -d: Doesn’t log the halt to /var/log/wtmp. By default, the halt is noted in this file.
o    -f: Forces a halt or reboot without calling shutdown.
o    -i: Shuts down network interfaces before halting.
o    -n: Doesn’t sync the file systems before halting.
o    -w: Writes a record of a halt to /var/log/wtmp but doesn’t actually halt the system.
Warnings: Care needs to be taken with this command. The -n flag, halting the system without syncing the disks, is of special concern because failing to sync the file systems before unmounting them can corrupt the data stored on them.
head:
Displays the first part of one or more files. By default, unless otherwise specified, the first 10 lines of each file are displayed. If no filenames are provided, then reads data from the standard input and displays the first section of the data, following the same rules as for files.
Syntax: head [-c number[bkm]] [-n number] [-qv] [--bytes number[bkm]] [--lines number] [--quiet] [--silent] [file ...]
Flags & Options:
o    -c/--bytes number: Displays the specified number of bytes from the start of each file. Optionally, the number can be followed by b for 512-byte blocks, kfor kilobytes, and m for megabytes.
o    -n/--lines number: Displays the specified number of lines from the start of each file.
o    -q/--quiet/--silent: Prevents printing of filename headers when multiple files are being processed.


hostname:
Displays or sets the system’s host name. If no flags or arguments are given, then the host name of the system is displayed.
Syntax: hostname [-a] [--alias] [-d] [--domain] [-f] [--fqdn] [-i] [--ip-address] [--long] [-s] [--short] [-y] [--yp] [--nis]
Flags & Options:
o    -a/--alias: Displays the alias name of the host if available.
o    -d/--domain: Displays the DNS domain name of the host.
o    -f/--fqdn/--long: Displays the fully qualified domain name of the host.
o    -i/--ip-address: Displays the IP address of the host.
o    -s/--short: Displays the host name without the domain name.
o    -y/--yp/--nis: Displays the NIS domain name of the system.

id:
Displays real and effective user and group ID information for a specified user. If no user is specified, then prints the information for the user running id.
Syntax: id [-gnruG] [--group] [--name] [--real] [--user] [--groups] [username]
Flags & Options:
o    -g/--group: Prints only the group ID.
o    -G/--groups: Prints only the supplementary groups.
o    -n/--name: Prints the user or group name instead of the ID number. Used in conjunction with -u, -g, or -G.
o    -r/--real: Prints the real user or group ID instead of the effective ones. Used in conjunction with -u, -g, or -G.
o    -u/--user: Prints only the user ID.
Ifconfig:
Configures a network interface, or displays its status if no options are provided. If no arguments are provided, the current state of all interfaces is displayed.
Syntax:  ifconfig interface options address
Flags & Options:
o    interface: Specifies the name of the network interface (e.g., eth0or eth1).
o    up: Activates the specified interface.
o    down: Deactivates the specified interface.
o    netmask address: Sets the network mask for the interface.
o    broadcast address: Sets the broadcast address for the interface.
o    pointtopoint address: Enables point-to-point mode for an interface, implying a direct link between two machines. Also sets the address for the other end of the link.
o    address: Specifies the host name or IP address for the interface. This is required.

ifdown:
Disables a specified interface, such as eth0 or eth1.
Syntax: ifdown interface
ifport:
Sets the transceiver type for a specified network interface.
Syntax:  ifport interface type
Flags & Options:
o    type: Specifies transceiver type. Possible types include: auto (automatic selection); 10baseT (twisted-pair Ethernet); 10base2 (coaxial-cable Ethernet); aui(AUI interface Ethernet); 100baseT (twisted-pair Fast Ethernet).
ifup:
Enables a specified interface, such as eth0 or eth1.
Syntax: ifup interface
Insmod:
Installs a loadable module into the current kernel.
Syntax: insmod [-fpsxX] [-o module_name] object_file [symbol=value ...]
Flags & Options:
o    -f: Tries to load the module even if the version of the kernel and the expected kernel version do not match.
o    -o module: Explicitly names the module instead of basing the name on the object file for the module.
o    -p: Probes the module to make sure it is loaded.
o    -s: Logs activity to the system log daemon rather than standard output.
o    -x: Doesn’t export the module’s external symbols.
o    -X: Exports the module’s external symbols (this is the default).
kbd_mode:
Displays or sets the keyboard mode.
Syntax: kbd_mode [-a|-u|-k|-s]
Flags & Options:
o    -a: Sets the keyboard to ASCII (XLATE) mode.
o    -k: Sets the keyboard to keycode (MEDIUMRAW) mode.
o    -s: Sets the keyboard to scanmode (RAW) mode.
o    -u: Sets the keyboard to UTF-8 (UNICODE) mode.

kbdrate:
Sets the repeat rate and delay time for the keyboard.
Syntax: kbdrate [-r rate] [-d milliseconds]
Flags & Options:
o    -d milliseconds: Sets the delay (before repeating) to the specified number of milliseconds.
o    -r cps: Sets the repeat rate to the specified number of characters per second. Not all values are possible. You should select from the following values: 2.0, 2.1, 2.3, 2.5, 2.7, 3.0, 3.3, 3.7, 4.0, 4.3, 4.6, 5.0, 5.5, 6.0, 6.7, 7.5, 8.0, 8.6, 9.2, 10.0, 10.9, 12.0, 13.3, 15.0, 16.0, 17.1, 18.5, 20.0, 21.8, 24.0, 26.7, 30.0.
kill:
Sends a kill signal to one or more running processes.
Syntax: kill [-s signal|-p] pid ...
kill -l
Flags & Options:
o    -l: Displays a list of signal names.
o    -p: Prints the process ID of a specified process rather than sending it a signal.
o    -s signal: Sends the specified signal to the specified processes.
o    pid: Specifies either the ID of a process or its name. When specifying processes by name, all processes with the specified name will receive the signal.
killall:
Sends a signal to all processes sharing a common process name.
Syntax: killall [-ei] [-signal] process ...
killall -l
Flags & Options:
o    -e: Forces the program to send the signal to only exact matches for process names longer than 15 characters.
o    -i: Asks for confirmation before sending the signal to each process.
o    -l: Displays a list of signal names.
ksyms:
Displays information about exported kernel symbols, including the address, name, and defining module.
Syntax: ksyms [-a] [-m]
Flags & Options:
o    -a: Displays all symbols, including those from the actual kernel.
o    -m: Displays module information, including the address and size of the module.

last:
Displays a history of user logins and logouts based on the contents of /var/log/wtmp. If a specific tty such as tty0 or tty1 is specified, then only logins to that tty are displayed.
Syntax: last [-R] [-number] [-n number] [-adx] [name ...] [tty ...]
Flags & Options:
o    -a: Forces the host name to be displayed in the last column.
o    -d: In the case of remote logins, displays all IP addresses as host names.
o    -n number/-number: Indicates how many lines of history to display.
o    -R: Suppresses the display of the host name in the report.
o    -x: Causes system shutdown and run level changes to be displayed along with logins and logouts.
ldd:
Displays shared library dependencies for one or more programs.
Syntax: ldd [-dr] program ...
Flags & Options:
o    -d: Reports missing functions after performing relocations.
o    -r: Reports missing data objects and functions after performing relocations.
less:
Displays a text file one screen at a time while allowing searching and backward scrolling.
Syntax: less [-aeEGiINrsS] file ...
Flags & Options:
o              -a: Causes searching to start after the last line on the screen. By default, searches include visible text.
o    -e: Causes less to exit the second time it encounters the end of a file. Otherwise, users must quit with the "q" command.
o    -E: Causes lessto exit the first time it encounters the end of a file.
o    -G: Suppresses highlighting of strings found by a search.
o    -i: Causes searches to be case insensitive. This is ignored if the search pattern includes uppercase letters.
o    -I: Causes searches to be case insensitive even when the search pattern contains uppercase letters.
o    -N: Causes a line number to be displayed at the beginning of each line.
o    -r: Causes raw control characters to be displayed using caret notation (e.g., Ctrl+A is ^A).
o    -s: Squeezes consecutive blank lines into a single blank line.
o    -S: Chops lines wider than the screen rather than wrapping them to the next line.
lilo:
Installs the Linux boot loader.
Syntax: lilo [C file] [-d deciseconds] [-q] [-D label] [-u device]
Flags & Options:
o    -C file: Specifies a specific configuration file to use in loading the boot loader. The default configuration file is /etc/lilo.conf.
o    -d deciseconds: Indicates the number of deciseconds to wait at the Lilo prompt during booting before loading the default kernel.
o    -D label: Uses the kernel with the specified label as the default kernel rather than the first kernel in the configuration file.
o    -q: Displays the currently mapped files listing the kernels to be booted.
o    -u device: Uninstalls the boot loader for the specified device.

No comments:

Post a Comment