ls /bin /usr/bin /usr/sbin | sort | uniq | grep -i Postfix //this
command returned no entries. This means Postfix binaries are not installed on this machine.
groupadd groupname //adds a new group. The /etc/group file contains all the grops
usermod -a -G groupname username //Add an Existing User to a Group
usermod -g groupname username //Change a User’s Primary Group
id username //to see what groups the user is assigned to
groups username //to see what groups the user is assigned to
groups //To view all the groups on the system
service mysqld start //runs mysqld available under /etc/rc.d/init.d. To automatically start and stop a service create symbolic links for /etc/rc.d/init.d/mysqld under /etc/rc.d/rc3.d/S99mysqld and /etc/rc.d/rc0.d/K01mysqld
service mysqld stop //runs mysqld available under /etc/rc.d/init.d
chkconfig --list //displays whether a service is enabled at various run levels.
nautilus . //opens the current directory in the file browser
Shell scripting:
Shell scripts are essentially text files containing sequences of statements that can be executed within the shell environment to perform tasks. In addition to the ability to execute commands, the shell provides many of the programming constructs such as for and do loops and if statements that you might reasonably expect to find in a scripting language.
The first step in creating a shell script is to create a file (for the purposes of this example we name it simple.sh) and add the following as the first line:
#!/bin/sh
The #! is called the shebang and is a special sequence of characters indicating that the path to the interpreter needed to execute the script is the next item on the line (in this case the sh executable located in /bin). This could equally be, for example, /bin/csh or /bin/ksh if either were the interpreter you wanted to use.
The next step is to write a simple script:
#!/bin/sh
for i in *
do
echo $i
done
All this script does is iterate through all the files in the current directory and display the name of each file. This may be executed by passing the name of the script through as an argument to sh:
sh simple.sh
In order to make the file executable (thereby negating the need to pass through to the sh command) the chmod command can be used:
chmod +x simple.sh
Once the execute bit has been set on the file’s permissions, it may be executed directly. For example:
./simple.sh
Filesystem layout (http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-filesystem-fhs.html):
File systems break files down into two logical categories:
-
Shareable vs. unsharable files
-
Variable vs. static files
Shareable files are those that can be accessed locally and by remote hosts;
unsharable files are only available locally.
Variable files, such as documents, can be changed at any time;
static files, such as binaries, do not change without an action from the system administrator.
/boot/ directory contains static files required to boot the system, such as the Linux kernel.
/dev/ directory contains device nodes that
either represent devices that are attached to the system or virtual
devices that are provided by the kernel. The
udev demon takes care of creating and removing all these device nodes in
/dev/.
Devices in the
/dev directory and
subdirectories are either character (providing only a serial stream of
input/output) or block (accessible randomly). Character devices include
mouse, keyboard, modem while block devices include hard disk, floppy
drive etc.
The
/etc/ directory is reserved for configuration files that are local to the machine. No binaries are to be placed in
/etc/. Any binaries that were once located in
/etc/ should be placed into
/sbin/ or
/bin/.
/lib/ directory should contain only those libraries needed to execute the binaries in
/bin/ and
/sbin/. These shared library images are
particularly important for booting the system and executing commands within the root file system.
/media/ directory contains subdirectories used
as mount points for removeable media such as usb storage media, DVDs,
CD-ROMs, and Zip disks.
/mnt/ directory is reserved for temporarily
mounted file systems, such as NFS file system mounts. For all removeable
media, please use the
/media/ directory. Automatically detected removeable media will be mounted in the
/media directory.
/opt/ directory provides storage for most application software packages.
A package placing files in the
/opt/
directory creates a directory bearing the same name as the package. This
directory, in turn, holds files that otherwise would be scattered
throughout the file system, giving the system administrator an easy way
to determine the role of each file within a particular package.
For example, if
sample is the name of a particular software package located within the
/opt/ directory, then all of its files are placed in directories inside the
/opt/sample/ directory, such as
/opt/sample/bin/ for binaries and
/opt/sample/man/ for manual pages.
Packages that encompass many different sub-packages, data files, extra fonts, clipart etc are also located in the
/opt/ directory, giving that large package a way to organize itself. In this way, our
sample package may have different tools that each go in their own sub-directories, such as
/opt/sample/tool1/ and
/opt/sample/tool2/, each of which can have their own
bin/,
man/, and other similar directories.
/proc/ directory contains special files that
either extract information from or send information to the kernel.
Examples include system memory, cpu information, hardware configuration
etc.
/sbin/ directory stores executables used by the root user. The executables in
/sbin/ are used at boot time, for system administration and to perform system recovery operations. Of this directory, the FHS says:
/sbin contains binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in /bin. Programs executed after /usr/ is known to be mounted (when there are no problems) are generally placed into /usr/sbin. Locally-installed system administration programs should be placed into /usr/local/sbin.
/usr/ directory is for files that can be shared across multiple machines. The
/usr/
directory is often on its own partition and is mounted read-only. At a
minimum, the following directories should be subdirectories of
/usr/:
/usr
|- bin/
|- etc/
|- games/
|- include/
|- kerberos/
|- lib/
|- libexec/
|- local/
|- sbin/
|- share/
|- src/
|- tmp -> ../var/tmp/
hierarchy is for use by the system
administrator when installing software locally. It needs to be safe from
being overwritten when the system software is updated. It may be used
for programs and data that are shareable among a group of hosts, but not
found in
.
/var/. Since the FHS requires Linux to mount
directory. The FHS states
directory. The
directory contains RPM system databases. Lock files go in the
directory, usually in directories for the program using the file. The
directory has subdirectories for programs in which data files are stored.