Linux Commands

       Linux commands can be  used configure and interact with Linux OS. The linux commands can be used at the shell prompt, or command prompt (Terminal). If you are using  linux in a GUI, try with the shell programming icon. If you do not have GUI then  you should be working with the shell prompt, and if you are signing through remote then you will be at the prompt. The two types of commands are shell commands and linux commands.

Linux Commands:

The Linux commands are not  shell commands. Each linux command is a individual executable program, thats written in  C-programming language. These executable programmes are stored in various physical directories such as /bin.The $PATH variable defines  the location of the directories. These linux commands differ from the linux distrubutions, and remains similar in any shell they are being used.

 Shell Commands:

The shell program consists of the shell commands. There are different kind of shells likely  bash shell, C shell, bourne shell etc. Each shells have variance in them. The commands structure vary between shells, but each shell is same among different linux platforms.

 The Command Prompt:

The prompts look is depend on the shell you use, and the settings you have for that shell.
The bash shell have the prompt set up like the following

[adm@cric home]#

Here the user logged is adm, and the computer name is  cric where the folder is home. The password file(pwd) is to be used to get full path.


Your prompt is bound to look different, so for the purpose of this section I will just use the > to represent the prompt.
>

Linux Commands:

Some linux commands are very simple and need nothing more than the command itself.
For example the command ls (list) will simply list the names of the directories and files in the current directory...
>ls
files/
images/
index.txt
>
In this instance ls shows there are two directories, called files and images, and a text file called index.
However you can often add options or parameters, which are usually added to the command after a '-'.
Adding the option -l will give you a long listing which includes the permissions, ownership, size, date/time, and name of the files and directories...
>ls -l
drwx------ 2 bob bob 4096 Aug 22 10:31 files/
drwx------ 3 bob bob 4096 Mar 19 11:17 images/
-rwx------ 1 bob bob 284 Mar 18 10:23 index.txt
>
Another example would be adding -a (ls -a) to list ALL the files in the current directory, including hidden files.
>ls -a
.hiddenfile
files/
images/
index.txt
>
This shows there is a hidden file (hidden files have a '.' before the filename) called '.hiddenfile', as well as the two directories and index file.
You can use more that one option at a time...
>ls -la would produce a long listing format of ALL (including hidden) directories and files in the current working directory.
There are many options for some linux commands, and the best place to find out about then all is the 'man' pages. These man pages show you how to format the command, and what options and parameters there are to use with each command.

 Few Basic commands

#free  -shows free RAM space
#date -current date
#time -shows system time
#cp
-to copy a file or directory#mkdir dir1   -to create directory
#rmdir dir1    -to remove a directory


Locate command is works only on linux kernel. It displays the absolute path for the search term.locate reads from the database created by the updatedb command. Locate does not check the existance of the file. Here is the usage for the locate command.

$ locate -h
Usage: locate [OPTION]... [PATTERN]...
Search for entries in a mlocate database.

  -b, --basename         match only the base name of path names
  -c, --count            only print number of found entries
  -d, --database DBPATH  use DBPATH instead of default database (which is
                         /var/lib/mlocate/mlocate.db)
  -e, --existing         only print entries for currently existing files
  -L, --follow           follow trailing symbolic links when checking file
                         existence (default)
  -h, --help             print this help
  -i, --ignore-case      ignore case distinctions when matching patterns
  -l, --limit, -n LIMIT  limit output (or counting) to LIMIT entries
  -m, --mmap             ignored, for backward compatibility
  -P, --nofollow, -H     don't follow trailing symbolic links when checking file
                         existence
  -0, --null             separate entries with NUL on output
  -S, --statistics       don't search for entries, print statistics about each
                         used database
  -q, --quiet            report no error messages about reading databases
  -r, --regexp REGEXP    search for basic regexp REGEXP instead of patterns
      --regex            patterns are extended regexps
  -s, --stdio            ignored, for backward compatibility
  -V, --version          print version information
  -w, --wholename        match whole path name (default)

updatedb - can be run only as root. This updates or creates a database for locate utility.

# updatedb -h
Usage: updatedb [OPTION]...
Update a mlocate database.

  -f, --add-prunefs FS           omit also FS
  -e, --add-prunepaths PATHS     omit also PATHS
  -U, --database-root PATH       the subtree to store in database (default "/")
  -h, --help                     print this help
  -o, --output FILE              database to update (default
                                 `/var/lib/mlocate/mlocate.db')
      --prunefs FS               filesystems to omit from database
      --prunepaths PATHS         paths to omit from database
  -l, --require-visibility FLAG  check visibility before reporting files
                                 (default "true")
  -v, --verbose                  print paths of files as they are found
  -V, --version                  print version information

The lists of paths and filesystems to omit default to values read from
`/etc/updatedb.conf'.

0 comments:

hits count
Database | Oracle PartnerNetwork Blog