Services > Desktop > Linux > Linux FAQ

LINUX FAQ and WHERIS SHEET

  1. What is the present version of os (e.g. Redhat 7.2)?
  2. How can I tell what version of the kernel I'm running, (e.g. 2.4)?
  3. How can I tell who is using a file?
  4. What task is using a port?
  5. How long since last reboot?
  6. Where are packages stored?
  7. What packages are installed?
  8. What is my present shell?
  9. How do I alter the default global path?
  10. How to alter the user directory path?
  11. How do I set my prompt?
  12. Where are the routing tables stored?
  13. Where are the ifconfig's stored?
  14. Where is the hostname stored?
  15. Where is the domain name stored?
  16. How to start network services via xinetd?
  17. How to turn on security logging?
  18. How to maximize general logging output?
  19. How Do I Resize a Partition Non-Destructively?
  20. How to make a rescue floppy.
  21. I forgot the root password, now what?
  22. What are Linux run levels and how can I see which programs and applications are running in each run level?
  23. How can I make run level changes, such as stopping and starting programs and applications?
  24. What are some networking commands?
  25. Linux Boot Process.
  26. /proc - a Virtual File System.
  1. What is the present version of os (e.g. Redhat 7.2)?
    A. To find the version of Red Hat Linux you are currently running, cat or more the following file:

    # more /etc/redhat-release
    Red Hat Linux release 9 (Shrike)

  2. How can I tell what version of the kernel I'm running, (e.g. 2.4)?
    A. By typing the following:

    # uname -r
    2.4.20-8
    # uname -a
    Linux brevryss.whoi.edu 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux

    NOTE: This same information is also found on reboot. When rebooting your system, there will be a window asking you to select version of RH OS to run, type “e” for edit here. You will see another screen similar to the first but will display the kernel version info similar to above.

  3. How can I tell who is using a file?
    A. By typing the following, (must be run as root):

    # fuser -u /usr/bin/ssh
    /usr/bin/ssh: 2338e(root) 7123e(root) 7191e(root)

  4. What task is using a port?
    A. The following methods and commands can be used to determine this information: Must be run as root, this will not work unless you are root, type;

    # fuser -n tcp 25 (This command gives you the process id that is using TCP port 25 )

  5. How long since last reboot?
    A. By running the command: 'uptime' You can determine how long the system has been running between system reboots. Example:

    # uptime
    16:25:08 up 5:54, 8 users, load average: 0.12, 0.14, 0.11

    “16:25:08” is current time, “5:54” is the time in hours and minutes, 5 hour and 54 minutes, the rest is self explanatory.....

  6. Where are packages stored?
    A. This is not so easy to define. “There is no standardization” of where Linux installs its packages. To find a particular package, lets say Perl, it is suggested to do the following:

    # rpm -ql perl (this lists all of the files added to the file system when the Perl package was installed, and where they were placed).

    So, you don't know the package name or you just want to know what packages were installed and where you might be able to find them, you might try:

    # rpm -qla | more (This will give you more information than you'll ever want to know...).

    This command will list ALL installed packages, where they were placed and display them one screen at a time. There are a lot of them on an RPM based system! See example:

    [root@ernest root]# rpm -qla |more
    /etc/X11/desktop-menus
    /etc/X11/desktop-menus/applications.menu
    /etc/X11/desktop-menus/preferences.menu
    /etc/X11/desktop-menus/server-settings.menu
    /etc/X11/desktop-menus/start-here.menu
    /etc/X11/desktop-menus/system-settings.menu
    /etc/X11/starthere
    /etc/X11/starthere/applications.desktop
    /etc/X11/starthere/preferences.desktop
    /etc/X11/starthere/serverconfig.desktop
    /etc/X11/starthere/sysconfig.desktop
    /usr/share/applications
    /usr/share/desktop-menu-files
    /usr/share/desktop-menu-files/Accessibility.directory
    /usr/share/desktop-menu-files/Accessories.directory
    /usr/share/desktop-menu-files/Advanced.directory
    /usr/share/desktop-menu-files/AllPrograms.directory
    /usr/share/desktop-menu-files/Applications.directory
    /usr/share/desktop-menu-files/Development.directory
    /usr/share/desktop-menu-files/Documentation.directory
    /usr/share/desktop-menu-files/Extras.directory
    /usr/share/desktop-menu-files/Games.directory

  7. What packages are installed?
    A. For distributions that use RPM format packages, use the command:

    $ rpm -qa (q=querry, a=all packages)

    You need to be logged in as root You can save the output to a text file for future reference, by using a command like;

    rpm -qa > installed-packages

  8. What is my present shell?
    A. By typing: 'echo $SHELL' at the prompt, you will get output similar to the
    following:

    [root@ernest root]# echo $SHELL
    /bin/bash
    [root@ernest root]#

    (depending on which shell you're using). To change your shell you can simply type:

    bash-$> setenv SHELL tcsh
    bash-$> export SHELL
    bash-$> echo $SHELL
    tcsh

    This will only change the shell for this login event. To change it to another shell for every login, you'll need to edit your ~/.login file.

  9. How do I alter the default global path?
    A. By editing the /.login (/.profile, /.bashrc or tcshrc, etc) file and editing the PATH=$PATH:line. Very similar to the answer for question 10.

  10. How to alter the user directory path?
    A. First, lets see what's in your path; type $PATH. See the following example:

    # [root@ernest root]# echo $PATH
    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
    Now for making changes to the user directory path. Edit /etc/.profile, (for system- wide settings) or ~/.bash_profile (user specific settings, may also be ~/.tcsh_profile) and add this line; 'export PATH=$PATH:[directory to be added]'. On your next login this directory will become part of your $PATH. If you only want that directory added for this login session type the same line as above but at a command line prompt:

    # set PATH=$PATH:[directory to be added] ; export PATH (this is for bourn shell), for other shells i.e. bash or tcsh, try:

    setenv PATH $PATH:[directory to be added]

  11. How do I set my prompt?
    A. Various people and distributions set their $PS strings in different places. The most common places are /etc/profile, /etc/bashrc, ~/.bash_profile, and ~/.bashrc.
    It should be stressed that PS1=..blah.. should be set in .bashrc and not .profile.

    The reason PS1 string should be set in .bashrc. is because non-interactive bashes go out of their way to unset PS1. The bash man page tells how the presence or absence of PS1 is a good way of knowing whether one is in an interactive vs non- interactive (ie script) bash session.

    Example:

    [ayork@gladius]$more .bashrc
    PS1="[\u@\h]\$" (which gives me the string: [ayork@gladius]$)

    If I edit this file and change the line to read: PS1="[\w] \u:\h -> " then I get the following PS1 prompt:

    [~] ayork:gladius -> (my new prompt)

  12. Where are the routing tables stored?
    A. The routing table is not a file, but the routing information is stored in the kernel. You can use the command “route -n” to display the table. The route table is empty on boot.

    # route -n
    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    128.128.92.0 0.0.0.0 255.255.252.0 U 0 0 0 eth0
    127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
    0.0.0.0 128.128.92.1 0.0.0.0 UG 0 0 0 eth0

    You will need to configure the default route into the operating system, which writes it to the kernel forwarding table when networking is started. When making changes or modifying the route table, the /etc/sysconfig/network gets modified. Once the file has been modified, rather than rebooting, you can make your changes take effect by running:

    # /etc/init.d/network restart

    NOTE: Please do not use routed. CIS recommends that you turn off any and all un- necessary processes for security reasons. Routed is not used within the context of the WHOI domain.

  13. Where are the ifconfig's stored?
    A. There are many Configuration tools for various network configuration:

    They are:
    netconf A GUI interactive interface available on Red Hat 6.1
    linuxconf A GUI interactive interface available on Red Hat 6.1 which includes netconf configuration.
    netconfig A GUI step by step interface
    ifconfig A text based program to configure the network interface. Type "man ifconfig" for info.

    The programs listed above will modify values in the following files:

    /etc/sysconfig/network -Defines your network and some of its characteristics. /etc/HOSTNAME - Shows the host name of this host. IF your name is "myhost" then that is exactly the text this file will contain.
    /etc/resolv.conf - Specifies the domain to be searched for host names to connect to, the nameserver address, and the search order for the nameservers.
    /etc/host.conf - Specifies the order nameservice looks to resolve names.
    /etc/hosts - Shows addresses and names of local hosts.
    /etc/networks - Provides a database of network names with network addresses similar to the /etc/hosts file. This file is not required for operation.
    /etc/sysconfig/network-scripts/ifcfg-eth* - There is a file for each network interface. This file contains the IP address of the interface and many other setup variables.

  14. Where is the hostname stored?
    A. You have to keep address translation and DNS in mind here to fully grasp this answer. A host on a network is really known by it's IP address and ethernet address... Now on a network, you may give a system a name, or many names that match an IP address. So a machine may be known by several DNS names but locally the machine may have a totally different hostname.
    There is a command 'hostname' that when typed at the prompt, will return something similar to the following:

    [root@ernest root]# hostname
    ernest.whoi.edu
    The local host name will be found in the /etc/sysconfig/network file as well as /etc/hosts. For example:
    [root@ernest root]# more /etc/hosts
    127.0.0.1 ernest.whoi.edu localhost
    (This info is from a Red Hat 8 system.)

    You can also run the following command:

    [root@ernest root]# more /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=ernest.whoi.edu

  15. Where is the domain name stored?
    A. Without getting into a whole discussion about how DNS works and C-NAME
    files, the following answer is a 'short' answer if you will, simply for the purposes of this document. The domainname is in the /etc/resolv.conf. It should be the first line of 3. In the case of WHOI if you were to 'more /etc/resolv.conf ' you would see the following:

    # more /etc/resolv.conf
    domain whoi.edu
    nameserver 128.128.16.1
    nameserver 128.128.16.2

    NOTE:
    The 'domainname' is not necessary in a non-NIS network. For Linux purposes here at WHOI, the above answer is correct. However if trying to discover the answer to the question on an NIS network, then typing 'domainname' at the prompt, should get a similar result to the following:

    # domainname
    whoi.edu

  16. How to start network services via xinetd?

    A. xinetd "/etc/init.d/xinetd start" (stop and restart arguments as well.)

  17. How to turn on security logging?
    A. Syslogd is the daemon which does the actual logging. The configuration file for syslogd is /etc/syslog.conf. Basically, syslogd puts time-stamped messages into log files as designated by syslog.conf. The log files can then be viewed to construct a history of the events occurring on your system. Syslogd is started along with the other startup scripts in /etc/rc.d/rc3.d or /etc/rc.d/rc5.d.

    Security precautions to take:

    Make sure the time is correct on your system. Otherwise you will have trouble tracing problems and breakins. System logs are generally kept in the /var partition, mainly /var/log. Make sure that /var is large enough to hold much more than the basic log file. This is to prevent accidental overflows, which could potentially erase important logging info.

    The default syslog.conf does not do a very good job of logging. Try changing the entry for /var/log/messages to:

    *.info /var/log/messages

    If you start getting too much of a certain message (say from sendmail), you can always bump that particular facility down by doing:

    *.info;mail.none /var/log/messages

    Many other security programs such as ssh and tcpwrappers will log to syslogd. It is important that syslogd is always running on your system.

    Additional security precautions to take:

    Turn off inetd, sendmail, everything, but make sure you have basic networking up. Make sure the time is always correct on the loghost. In order to allow the loghost to receive syslog messages from other machines, you may need to enable it to receive remote logging. (Find out first by reading the syslogd man pages). Do this by adding the r command line upon syslogd startup.

    Edit /etc/rc.d/init.d/syslog, and find the line:

    daemon syslogd

    and change it to:

    daemon syslogd -r

    Next, tell all of your clients to log to this machine in addition to their local files. This can by done by adding a line which designates the action as the loghost, with an "@" sign in front of it to the bottom of /etc/syslog.conf:

    *.info @logboy.caltech.edu

    Once you restart syslogd, the client will send all of its log messages to logboy.caltech.edu, which will also then log the messages to its local files. Be sure that the client is able to resolve logboy.caltech.edu at all times. A suggestion is to add a special entry in /etc/hosts so that logging is not interrupted if there is a resolving problem.

    Again, make sure the loghost is as secure as possible: the only thing it should be running is syslogd.

  18. How to maximize general logging output?
    A. Linux logs are in plain text, so you can search and read them without having to use special tools. You can also write scripts that scan through logs and perform automatic functions based on the contents. Linux logs are contained in the
    /var/log directory. There are several log files that are maintained by the system, but other services and programs may put their log files here too. Most logs are only readable by root, but that can be changed by simply changing the access rights to the file.

    The /var/log/messages file is the core system log file. It contains the boot messages when the system came up as well as other status messages as the system runs. Errors with IO, networking, and other general system errors are reported in this file. Other information, such as when someone becomes root, is listed here as well. If services are running, such as DHCP servers, you can watch the action in the messages file. /var/log/messages is generally your first place to
    look when you are troubleshooting.

    Example:

    [root@ernest root]# more /var/log/messages (or less, head, tail...)
    ernest syslogd 1.4.1: restart.
    Mar 1 11:16:23 ernest sshd(pam_unix)[11881]: session opened for user cstock by (uid=500)
    Mar 1 11:16:46 ernest sshd(pam_unix)[11881]: session closed for user cstock Mar 1 11:28:04 ernest sshd(pam_unix)[12040]: authentication failure; logname= uid=0 euid=0 tty=NODEVssh ruser= rhost=saul.whoi.edu user=cstock
    Mar 1 11:28:07 ernest sshd(pam_unix)[12042]: session opened for user cstock by (uid=500)
    Mar 1 11:28:07 ernest sshd(pam_unix)[12042]: session closed for user cstock Mar 1 11:29:44 ernest sshd(pam_unix)[12083]: authentication failure; logname= uid=0 euid=0 tty=NODEVssh ruser= rhost=saul.whoi.edu user=cstock
    Mar 1 11:29:47 ernest sshd(pam_unix)[12085]: session opened for user cstock by (uid=500)

    [root@ernest root]# dmesg (Kernel boot log).

    This log is also available in the file /var/log/dmesg.

  19. How Do I Resize a Partition Non-Destructively?
    A. GNU parted, a partition editor, is stable enough for non-guru, mere-mortal use with relative confidence. Source code for the latest version is at: ftp.gnu.org/pub/gnu/parted/.

    There's also a boot disk image for resizing root partitions and for running parted on non-Linux machines. The disk image may be easier for beginners. Building from source could require some extra configuration. Parted also has
    tutorial-style, plain-text documentation for Linux and FAT (MS-DOS) file systems.

    Also, some commercial distributions come with their own partitioning software, like Partition Magic.

  20. How to make a rescue floppy.
    A. Make a file system on the floppy with bin. Etc, lib and dev directories, everything you need. Install a kernel on it and arrange to have GRUB (or LILO) boot it from the floppy, (see GRUB (or LILO) documentation). If you build the kernel, (or tell GRUB (LILO) to tell the kernel...) to have a RAM disk the same size as the floppy, the RAM disk will be loaded at boot time and get mounted as root in place of the floppy. See the Bootdisk HOWTO.
  21. I forgot the root password, now what?
    A. If your Linux distribution permits, try booting into single-user mode by typing “single” at the BOOT prompt. With more recent distributions, you can boot into single-user mode when prompted by typing “linux 1", "linux single”, or “init=/bin/bash”.

    If the above doesn't work for you, boot from the installation or rescue floppy, and switch to another virtual console with Alt-F1 – Alt-F8, and then mount the root file system on /mnt. Then proceed with the steps below to determine if your system has standard or shadow passwords, and how to remove the password.

    Using your favorite text editor, edit the root entry of the /etc/passwd file to remove the password, which is located between the first and second colons. '''Do this ONLY if the password field does not contain an 'x', in which case see below.''

    root:Yhgew13xs:0:0:...

    Change this to:

    root::0:0:...

    If the password field contains an 'x', then you must remove the password from the /etc/shadow file, which is in a similar format. Refer to the manual pages:
    man passwd, and man 5 shadow.

  22. What are Linux run levels and how can I see which programs and applications are running in each run level?
    A. Linux has 6 different run levels (or operating modes):

    rc1.d - Single User Mode
    rc2.d - Single User Mode with Networking
    rc3.d - Multi-User Mode - boot up in text mode
    rc4.d - Not yet Defined
    rc5.d - Multi-User Mode - boot up in X Windows
    rc6.d – Shutdown

    Each mode has it's own list of settings for what services to start and what services to shutdown. Not only does this list contain what is supposed to be running, but also what order each service should be started in.

    The 'chkconfig' command will list all the registered services and display their status at each different run level. Most of the time when your server boots up it will start in run level 3 or 5 depending on what it is set to. This setting can be found in the file /etc/inittab. If you ever want to change what mode your server defaults to on bootup, just edit that file, but NEVER change it to run level 6 or else you will set your server to shutdown on bootup.

    Example:
    [root@ernest root]# chkconfig –list (will list the following info, including services info)
    ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
    syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
    network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    random 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    .....etc.....
    xinetd based services:
    chargen-udp: off
    chargen: off
    daytime-udp: off
    ....etc.......

    In the folder: /etc/rc.d are all the run level folders starting from rc1.d to rc6.d and including init.d.

    It is in each of these rc#.d folders where the service run settings are kept. If you change directory into /etc/rc.d/rc3.d all the files that start with a capital S are the services that will start at this run level. All the files that start with a K are the services that will be killed at that run level.
  23. How can I make run level changes, such as stopping and starting programs and applications?
    A. First determine which run level a current application or program is in by running the 'chkconfig' (Red Hat and Mandrake Linux systems )command with the argument '--list'. Then edit the / etc/rc.d/{runlevel.d} file. For example, in the answer above we ran the 'chkconfig --list' command and argument. Taking the line from the output with 'syslog' we'll demonstrate how this changes.

    Example:

    # chkconfig --list
    syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off

    This shows us that syslog is currently turned off in run levels 1 and 6, and turned on in run levels 2, 3, 4, and 5. Lets say you want this turned of for run levels 2 and 4 as well.

    # cd /etc/rc.d/rc2.d
    # pwd
    /etc/rc.d/rc2.d
    # ls
    S12syslog
    # mv S12syslog K12syslog
    # ls
    K12syslog
    Do the same for run level 4. Now run chkconfig –list again.

    # chkconfig –list
    syslog 0:off 1:off 2:off 3:on 4:off 5:on 6:off

    For other Linux Distributions:

    A. (Debian): The program "update-rc.d" is a root-only program in Debian for setting whether particular init.d scripts are run when entering particular run levels. See the man page update-rc.d(8).

    Its chief parameter is the name of an init.d script. This should be the bare name (without directory) of a script in /etc/init.d. This script MUST accept the "start" and "stop" parameters.

    To cause an init.d script to be started in the default run levels (2, 3, 4, and 5) and stopped in the shutdown and single-user run levels (0, 1, and 6):

    # update-rc.d scriptname defaults

    To cause an init.d script to NOT be started or stopped:

    update-rc.d scriptname remove

    To specify which run levels to start and stop in, for instance, to start in 5 and stop in all others:
    update-rc.d scriptname start 5 stop 0 1 2 3 4 6

    NOTE: Normally you do not need to use "update-rc.d" yourself, as Debian packages for daemons run it for you with their own defaults when added or removed. Because it is easy to add and remove packages in Debian, the normal thing to do is to _uninstall_ a package if you do not want it running. Note also that "update-rc.d" does NOT start or stop the daemon itself. All it does is create or remove symlinks in the /etc/rc?.d directories.

  24. What are some networking commands?
    A. Network Analysis Tools:

    netstat - Displays information about the systems network connections, including port connections, routing tables, and more.
    netstar -r" will display the routing table.
    traceroute - This command can be used to determine the network route from your computer to some other computer on your network or the internet. To use it you can type "route IPaddress" of the computer you want to see the route to.
    nslookup - Used to query DNS servers for information about hosts.
    arp - This program lets the user read or modify their arp cache.
    tcpdump - This program allows the user to see TCP traffic on their network.
    dig(1) - Send domain name query packets to name servers for debugging or testing.
  25. Linux Boot Process.
    A. Before Red Hat Linux can start up on your system, it must be told to boot by special instructions placed on a boot loader, code that exists on your primary hard drive or other media device that knows how to start the Linux kernel.

    If you only use one version of the Linux kernel, then the exact process used by the boot loader to start Linux is not all that important. The Linux installation program allows you to quickly and easily configure the boot loader in your hard drive's Master Boot Record (MBR) to load the operating system.

    However, if you wish to have the choice to boot from multiple Linux kernels or other operating systems, then knowledge of the method used by Red Hat Linux to provide the necessary options to you, as well as an understanding of the boot process and what to change, is essential.

    How does the boot loader in the MBR know what to do when the MBR is read? There are 2 files depending on which version or distribution of Linux, LILO and GRUB. LILO actually has instructions written in the MBR which can be edited through the use of 'lilo' command to edit the /etc/lilo.conf configuration file. GRUB also has written the instructions in the /boot/grub/grub.conf configuration file. Regardless of which Boot loader you use it first loads the kernel into memory, then the kernel passes control to init.

    The kernel finds init in /sbin and executes it, and init coordinates the rest of the boot process. When init starts, it becomes the parent or grandparent of all of the processes that start up automatically on your Linux system. First, it runs the
    /etc/rc.d/rc.sysinit script, which sets your path, starts swapping, checks the filesystems, and so on. Then, init runs the /etc/inittab script, which describes how the system should be set up in each runlevel and sets the default runlevel.

    Next, init starts all of the background processes necessary for the system to run by looking in the appropriate rc directory for that runlevel, /etc/rc.d/rc(x).d, where the xis numbered (0-6). After init has progressed through all of the runlevels, the /etc/inittab script forks a getty process for each virtual console (login prompts) for each runlevel (runlevels 2-5 get all six; runlevel 1, which is single user mode, only gets one console; runlevels 0 and 6 get no virtual consoles). This allows users to authenticate themselves to the system and begin to use it.

    SysV init is the standard init process in the Linux world to control the startup of software at boot time, because it is easier to use and more powerful and flexible than the traditional BSD init. SysV init also differs from BSD init in that the configuration files are in /etc/rc.d instead of residing directly in /etc. SysV init represents each of the init runlevels with a separate directory, using init and symbolic links in each of the directories to actually stop and start the services as the system moves from runlevel to runlevel. In summary, the chain of events for a SysV init boot is as follows:

  • The kernel looks in /sbin for init
  • init runs the /etc/rc.d/rc.sysinit script
  • rc.sysinit handles most of the boot loader's processes
  • init runs all the scripts for the default runlevel
  • init runs /etc/rc.d/rc.local

The default runlevel is decided in /etc/inittab. If you want to change the default, you can edit /etc/inittab by hand. Be very careful when you are editing the inittab file.

If you use LILO as your boot loader, you can fix the inittab file by rebooting, accessing the boot: prompt with [ctrl]-[x] and typing:

boot:linux single

    • If you are using GRUB as your boot loader, you can fix the inittab file with the following steps.
    • In the graphical GRUB boot loader screen, select the Linux boot label and press [e] to edit it.
    • Arrow down to the kernel line and press [e] to edit it.
    • At the prompt, type single and press [Enter]
    • You will be returned to the GRUB screen with the kernel information. Press the [b] key to boot the system into single user mode.
    • This should allow you to boot into single-user mode so you can re- edit inittab to its previous value.
  1. /proc - a Virtual File System.
    A. The /proc file system is a mechanism that is used for the kernel and kernel modules to send information to processes. This pseudo file system allows you to interact with the internal data-structure of the kernel, get useful information about processes, and change settings (by modifying the kernel parameters) on the fly. /proc is stored in memory, unlike other file-systems, which are stored on the disk.

    /proc is controlled by the kernel and does not have an underlying device. Because it contains mainly state information controlled by the kernel, the most logical place to store the information is in memory controlled by the kernel. Doing an
    'ls -l' on /proc reveals that most of the files are 0 bytes in size; Yet when the file is viewed, quite a bit of information is seen. This is because the /proc file-system, like any other regular file-system registers itself to the Virtual File System layer (VFS). However, when VFS make calls to it requesting i-nodes for files/directories, the /proc file system creates those files/directories from information within the kernel.

    /proc files can be used to access information about the state of the kernel, the attributes of the machine, the state of the running processes, etc. Most of the files in the /proc directory provide the latest glimpse of a system's physical environment. Although these /proc files are virtual, they can be viewed using any file editor or programs like 'more', 'less' or 'cat'. When any editor program tries to open a virtual file, the file is created on the fly from information within the kernel.

    [root@ernest root]# file /proc/cpuinfo
    /proc/cpuinfo: empty
    [root@ernest root]#

    Yet, if we try this:

    [root@ernest root]# cat /proc/cpuinfo
    processor : 0
    vendor_id : GenuineIntel
    cpu family : 15
    model : 2
    model name : Intel(R) Xeon(TM) CPU 2.40GHz
    stepping : 7
    cpu MHz : 2391.970
    cache size : 512 KB
    Physical processor ID : -1069960964
    Number of siblings : 1
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 2
    wp : yes

    (for example)

    The Proc File System can be used to gather useful information about the system and the running kernel. Some of the important files are listed below:

    /proc/cpuinfo - information about the CPU (model, family, cache size etc.) /proc/meminfo - information about the physical RAM, Swap space etc.
    /proc/mounts - list of mounted file systems
    /proc/devices - list of available devices
    /proc/filesystems - supported file systems
    /proc/modules - list of loaded modules
    /proc/version - Kernel version
    /proc/cmdline - parameters passed to the kernel at the time of starting

There are many more files in /proc than listed above.

The /proc file system can be used to retrieve information about any running process. There are a couple of numbered sub-directories inside /proc. Each numbered directory corresponds to a process id (PID). Thus, for each running process, there is a sub-directory inside /proc named by its PID. Inside these sub- directories are files that provide important details about the state and environment of a process.

[root@ernest root]# ps -aef | grep mozilla
cstock 19192 1 0 15:57 ? 00:00:05 /usr/lib/mozilla-1.0.1/mozilla-broot 19233 19086 0 16:23 pts/3 00:00:00 grep mozilla
[root@ernest root]#

The above command shows that there is a running process of mozilla with PID 32558. Correspondingly, there should be a directory in /proc with number 32558.

[root@ernest root]# ls -l /proc/19192
total 0
-r--r--r-- 1 cstock cstock 0 Mar 4 16:24 cmdline
-r--r--r-- 1 cstock cstock 0 Mar 4 16:24 cpu
lrwxrwxrwx 1 cstock cstock 0 Mar 4 16:24 cwd -> /home/cstock
-r-------- 1 cstock cstock 0 Mar 4 16:24 environ
lrwxrwxrwx 1 cstock cstock 0 Mar 4 16:24 exe -> /usr/lib/mozilla- 1.0.1/mozilla-bin
dr-x------ 2 cstock cstock 0 Mar 4 16:24 fd
-r--r--r-- 1 cstock cstock 0 Mar 4 16:24 maps
-rw------- 1 cstock cstock 0 Mar 4 16:24 mem
-r--r--r-- 1 cstock cstock 0 Mar 4 16:24 mounts
lrwxrwxrwx 1 cstock cstock 0 Mar 4 16:24 root -> /
-r--r--r-- 1 cstock cstock 0 Mar 4 16:24 stat
-r--r--r-- 1 cstock cstock 0 Mar 4 16:24 statm
-r--r--r-- 1 cstock cstock 0 Mar 4 16:24 status
[root@ernest root]#

There is much, much more interesting information on this. To read more check out this URL:

http://linuxfocus.org/English/January2004/article324.shtml

LINUX FILES

    syslog output control /etc/syslog.conf
    serial i/o stats /proc/tty/device/serial
    serial port baud rate /proc/tty/device/serial
    network startup /etc/rc.d/init.d/network [restart]
    network gw & hostna /etc/sysconfig/network
    network interfaces /etc/sysconfig/network-scripts
    allow ssh /etc/hosts.allow (sshd: hostname)
    deny ssh /etc/hosts.deny (ALL: ALL)
    allow routing /proc/sys/net/ipv4/ip_forward
    internet services inetd.conf
    exclude ftp users /etc/ftpusers
    allow root login via serial port /etc/securettys
    serial locks /var/lock
    module installed cards /etc/modules.conf
    ip routes /etc/iproute2
    ppp routing /etc/ppp/ip-up /etc/ppp/ip-down
    tcp/ip confiig parms /usr/src/linux/Documentation/networking/ip-sysctl.txt/proc/sys/net/ipv4/* (from doc above)
    domain name specify in search option of /etc/resolv.conf
    telinit q re-process the inittab
    telinit q re-process the inittab
    tcpdump tcpdump
    interface stats /proc/net/dev
    dev codewords major:minor - /usr/src/linux/Documentation/devices.txt

 

LINUX PROCEDURES

    replicate directory tree find treename -type d | cpio -pdum newtree
    bootup /etc/inittab is executed by initinit.d/rc.x scripts are executed by SUSE/etc/rc.d scripts are execurted by RH
    name resolution /etc/host.conf determines order of name resolution (e.g. DNS, hosts) /etc/resolve.conf contains DNS server IPs
    domain resolution to set domain name for this machine, add to resolve.conf:domain whoi.edu
    zmodem send a file: sz filename </dev/ttySnn >/dev/ttySnnrec a file: rz </dev/ttySnn >/dev/ttySnn
    DISKS backup incremental backup restore format a partition new filesystem disp superblks ufsdump 0uf /dev/rmt/n /dev/rdsk/cntmdxsyufsdump 9uf /dev/rmt/n /dev/rdsk/cntmdxsyufsrestore ivf /dev/rmt/n where n is the label numberformat /dev/rdsk/ cntmdxsynewfs –v /dev/dsk/cntmdxsy newfs –N /dev/dsk/cntmdxsy
    set boot runlevel /etc/inittab change line the n in line: x:n:respawn:/etc/X11/prefdm -nodaemon
    toggle consoles alt-f1 atl-f2 ….
    send data directly to the serial port cat “test data” > /dev/sttyS0
    nfs to share a file go to /etc/dfs/dfstab:share –F nfs –o rw=hostname1: hostname2:…. /directory
    setup 1) /etc/hosts – local and self is setup2) /etc/hosts – domain is defined3) /etc/hosts.allow and /etc/hosts.deny4) ifconfig – check ports5) netstat –rn check routes6) chkconfig – look for proper startup parms7) inittab – check start level8) inittab – check ctl/alt/del seq and remove –r option9) /etc/resolv.conf10) /proc/sys/net/ipv4/ip_forward set value to 1
    lilo 1) lilo is installed on the MBR using the lilo command. It's config is in etc/lilo.conf2) in the lilo.conf each bootable image is listed.The root=/dev/hdan parm tells lilo where to get the root file system and /boot from3) lilo starts at boot time when BIOS reads it in and gives it control4) lilo load the secondary boot loader from /boot/boot of the filesystem pointed to on the disk and sector of the root= parm5) the kernel from image parm of the config file is loaded6) to imbed a lilo boot image on a boot sector use: lilo -r target -c etc/target.lilo.conf
    make a ram disk # create a filesystem: mkfs.ext2 /dev/ramn# mount the ramdisk: mount /dev/ram0 /mnt
    make compressed image of ram disk for lilo install dd if=/dev/ram0 of=my_initrd.img bs=1kgzip -9 my_initrd.img
    load ram disk with lilo add the ramdisk= and initrd= to your lilo.conf:image=/boot/vmlinuzlabel=linram1root=/dev/hda1ramdisk=4096initrd=/boot/my_initrd.fle
    build kernel make xconfigmake depmake cleanmake bzImagemake modulesmake modules_installthe kernel will be found in:
    netcat nc send a file: listener: netcat -l -p 2871 > /dev/tty caller: cat rawdata| netcat listener.whoi.edu 2871send console input: listener: netcat -l -p 2871 > /dev/tty caller: netcat listener.whoi.edu 2871 < /dev/ttyrelay tcp from one machine to the next: nc -L remotehost:remoteport -plocalportlisten tcp and relay telneted remote to serial ports nc -l -plocalport </dev/ttySxx >/dev/ttySxx
    xwin on remote on local machine: xhost +remotenameon remove machine: export DISPLAY=localname:0.0
    build embedded image syslinux -s /dev/hdn where hdn contains:rootfs.img
    add secondary address to interface ifconfig eth0:1 10.0.0.99 netmask 255.0.0.0
    trace telnet telnetset tracefile filenameset netdata onopen host port


LINUX COMMANDS

    < ctl>z bg job fg job put job in the background/forground
    chkconfig change/show startup parameters
    df –k show % use of disks
    du -sh *
    df -k
    show file space utilization
    show disk space utilization
    free -m show mem util in meg
    killall - 9 prc kill all processes named prc
    ldd name show files used by name
    lpq display print q
    lprm –P dest purge dest
    lsof list open files
    mkfs.ext3 /dev/hdn make a filesystem on hdn
    mkisofs make a boot partition on linux CD
    mknod /dev/hdan b 3 3 make a dev for a primary disk partition
    mkswap /dev/hdan make a linux swap partition
    mount /dev/cdrom /mnt mount a cdrom
    mount -o loop mount a file instead of an fs
    mt –f /dev/rmt/0 cmdmt –f /dev/rmt/0n fsf n position tape to a file or tape markposition to tape mark n. Notice the 0n to hold the tape in position
    parted fdisk parition a disk
    pgrep prc list pids for all processes named prc
    procinfo show stuff about running procs
    rm -- -file remove file with name starting in "-"
    rpm -qa show rpms installed
    rpm -ql rpmname show files used by rpmname
    sar show various io stats
    scp secure copy:scp name1@fromhost1:file1 name2@tohost2:file2
    strings scan a file for printable strings
    tar -cf target.tar file1 file2 dir1 ….--exclude exfile -cf arch.tar infiles
    tunefs control frequency of fsck checking
    version of kernel uname –a
    who show who is logged in
    xcdroast copy a cd
    redirect error command 2>filename
    yes output a test string in a loop
    pidof process list the pid of process
    end telnet session <ctl> ]
    hexdump file dump a file in hex (also see od command)
    uptime time since las reboot

LINUX NETWORK COMMANDS

    tcp/ip info ip route; ip neigh; ip link
    ip route add default via add a default route using a specific porth
    route add –net x.x.x.x netmask y.y.y.y dev eth0 add a network route
    route del –net x.x.x.x netmask y.y.y.y del a network route
    ppp pppd –detach crtscts lock 10.1.1.2:10.1.1.1 /dev/ttyS0 9600 nodeflate nobsdcomp debug &
    ppp multilink pppd –detach crtscts lock 10.1.1.2:10.1.1.1 /dev/ttyS0 9600 multilink nodeflate nobsdcomp debug &pppd –detach crtscts
    lock 10.1.1.2:10.1.1.1 /dev/ttyS1 9600 multilink nodeflate nobsdcomp debug &
    pppstats  
    /sbin/arp –an show arp cache
    /etc/rc.d/init.d/network restart restart the network script
    ip route flush root 0/0 flush ip routes

VI

    replace all %s/hdisk2/hdisk5/gc
    join a line j

telnet stuff

    ctrl[ change to telnet command mode. sending return will resume session to remote