Freedom The Open Source Way Contribute Articles or News to OSForgeOSForge HomeLogout from Forums
Contacting OSForgeOSForge HomeAbout OSForge
  

Root
Contribute News
Learning Corner
Linux Distributions
Linux Common FAQ's
Discussion Forums
Community Gallery
Links Directory
Search OSForge
Networking
Industry Updates
Linux & Open Source
Opinions
Press Release
Programming
Security
Web Development

White Paper
Plat'Home Unveils Winners of “Will Linux Work?” Contest
Zenoss Core Recognized as Best Open Source Network Monitoring Solution
LinMin™ Joins Intel® Certified Software Solutions Program
xTuple™ ERP 3.0 Wins “Best Business Application” At LinuxWorld Conference & Exp
Holland Computing Center - Rocks+Moab Provides Windows/Linux Cluster Solution
LogMeIn Launches Mobile Plug-in for Linux
FuseMail Selects Funambol’s Open Source Push Email and PIM Sync Solution
Zenoss Expands IT Management Solution for Managed Service Providers
Moab Workload Manager Claims Title as World’s First Petaflop Scheduler
Moab Workload Manager Claims Title as World’s First Petaflop Scheduler

View More

Linux Newbie Guide IX - Linux Commands

Page: 2/6  [Printable Version]



Help commands

any_command --help |more
Display a brief help on a command (works with most commands).  For example, try cp --help |more. "--help" works similar to DOS "/h" switch. The "more" pipe is needed when the output is longer than one screen.

man topic
Display the contents of the system manual pages (help) on the topic. Press "q" to quit the viewer. Try man man if you need any advanced options.  The command info topic works similar to man topic, yet it may contain more up-to-date information. Manual pages can be hard to read--they were written for UNIX programmers. Try any_command --help for a brief, easier to digest help on a command. Some programs also come with README or other info files--have a look to the directory /usr/share/doc. To display manual page from a specific section, I may use something like: man 3 exit (this displays an info on the command exit from section 3 of the manual pages) or man -a exit (this displays man pages for exit from all sections).  The man sections are:  Section 1-User Commands, Section 2-System Calls, Section 3-Subroutines, Section 4-Devices, Section 5-File Formats, Section 6-Games, Section 7-Miscellaneous, Section 8-System Administration, Section 9, Section n-New.  To print a manual page, I use:  man topic | col -b | lpr  (the option col -b removes any backspace or other characters that could make the printed manpage difficult to read).

info topic
Display the contents of the info on a particular command. info is a replacement for man pages so it contains the most recent updates to the system documentation. Use <Space> and <BkSpace> to move around or you may get confused. Press "q" to quit.  A replacement for the somewhat confusing info browsing system might be pinfo - try if you like it any better.

apropos topic
Give me the list of the commands that have something to do with my topic.

whatis topic
Give me a short list of commands matching my topic. whatis is similar to apropos (see the command above)--they both use the same database. But whatis searches keywords, while apropos also searches the descriptions of the keywords.

help command
Display brief info on a bash (shell) built-in command. Using help with no command prints the list of all bash built-in commands. The shortest list of bash built-in commands would probably include: alias, bg, cd, echo, exit, export, fg, help, history, jobs, kill, logout, pwd, set, source, ulimit, umask, unalias, unset.

kdehelp
(in X-terminal). Browse the whole system help using the graphical KDE help navigator. Normally, KDE help is invoked by pressing the appropriate icon on the KDE control panel.  Use gnome-help-browser for the GNOME equivalent.

System info

pwd
Print working directory, i.e., display the name of my current directory on the screen.

hostname
Print the name of the local host (the machine on which I am working). Use netconf (as root) to change the name of the machine.

whoami
Print my login name.

id username
Print user id (uid) and his/her group id (gid), effective id (if different than the real id) and the supplementary groups.

date
Print or change the operating system date and time. E.g., I could change the date and time to 2000-12-31 23:57 using this command:
date 123123572000
To set the hardware (BIOS) clock from the system (Linux) clock, use the command (as root) setclock

time
Determine the amount of time that it takes for a process to complete + other info. Don't confuse it with the date command (see previous entry). E.g. I can find out how long it takes to display a directory content using:
time ls

who
Determine the users logged on the machine.

w
Determine who is logged on the system, find out what they are doing, their processor ussage, etc. Handy security command.

rwho -a
(=remote who) Determine users logged on other computers on your network. The rwho service must be enabled for this command to run. If it isn't, run setup (RedHat specific) as root to enable "rwho".

finger user_name
System info about a user. Try: finger root . One can use finger with any networked computer that exposes the finger service to the world, e.g., I can do (try): finger @finger.kernel.org.

last
Show listing of users last logged-in on your system.  Really good idea to check it from time to time as a security measure on your system.

lastb
("=last bad") Show the last bad (unsuccessful) login attempts on my system. It did not work on my system, so got it started with:
touch /var/log/btmp

"There's a good reason why /var/log/btmp isn't available on any sane set-up - it's a world-readable file containing login mistakes. Since one of the most common login mistakes is to type the password instead of the username, /var/log/btmp is a gift to crackers." (Thanks to Bruce Richardson).  It appears the problem can be solved by changing the file permissions so only root can use "lastb":
chmod  o-r /var/log/btmp
history | more
Show the last (1000 or so) commands executed from the command line on the current account. The "| more" causes the display to stop after each screenful.  To see what another user was doing on your system, login as "root" and inspect his/her "history".  The history is kept in the file .bash_history in the user home directory (so yes, it can be modified or erased).

uptime
Show the amount of time since the last reboot.

ps
(="print status" or "process status") List the processes currently run by the current user.

ps axu | more
List all the processes currently running, even those without the controlling terminal, together with the name of the user that owns each process.

top
Keep listing the currently running processes on my computer, sorted by cpu usage (top processes first). Press <Ctrl>c when done.

PID = process identification.
USER=name of the user who owns (started?) the process.
PRI=priority of the process (the higher the number, the lower the priority, normal 0, highest priority is -20, lowest 20.
NI=niceness level (i.e., if the process tries to be nice by adjusting the priority by the number given).
SIZE=kilobytes of code+data+stack taken by the process in memory.
RSS=kilobytes of physical (silicon) memory taken.
SHARE=kilobytes of memory shared with other processes.
STAT=state of the process: S-sleeping, R-running, T-stopped or traced, D-uniterruptable sleep, Z=zombie.
%CPU=share of the CPU usage (since last screen update).
%MEM=share of physical memory.
TIME=total CPU time used by the process (since it was started).
COMMAND=command line used to start the task (careful with passwords, etc., on command line, all permitted to run "top" may see them!
gtop
ktop
(in X terminal) Two GUI choices for top. My favourite is gtop (comes with gnome). In KDE, ktop is also available from the "K"menu under "System"-"Task Manager".

uname -a
(= "Unix name" with option "all") Info on your (local) server. I can also use guname (in X-window terminal) to display the info more nicely.

cat /etc/issue
Check what distribution you are using. You can put your own message in this text file--it's displayed on login. It is more common to put your site-specific login message to the file /etc/motd ("motd"="message of the day").

free
Memory info (in kilobytes).  "Shared" memory is the memory that can be shared between processes (e.g., executable code is "shared"). "Buffered" and "cashed" memory is the part that keeps parts of recently accessed files--it can be shrunk if more memory is needed by processes.

df -h
(=disk free) Print disk info about all the filesystems (in human-readable form).

du / -bh | more
(=disk usage) Print detailed disk usage for each subdirectory starting at the "/" (root) directory (in human legible form).

cat /proc/cpuinfo
Cpu info--it shows the content of the file cpuinfo. Note that the files in the /proc directory are not real files--they are hooks to look at information available to the kernel.

cat /proc/interrupts
List the interrupts in use.  May need to find out before setting up new hardware.

cat /proc/version
Linux version and other info.

cat /proc/filesystems
Show the types of filesystems currently in use.

cat /etc/printcap |more
Show the setup of printers.

lsmod
(= "list modules". As root. Use /sbin/lsmod to execute this command when you are a non-root user.) Show the kernel modules currently loaded.

set|more
Show the current user environment.

echo $PATH
Show the content of the environment variable "PATH". This command can be used to show other environment variables as well. Use "set" to see the full environment.

dmesg | less
Print kernel messages (the content of the so-called kernel ring buffer). Press "q" to quit "less". Use less /var/log/dmesg  to see what "dmesg" dumped into this file right after the last system bootup.

chage -l my_login_name
See my password expiry information.

sysctl -a |more
Display all the configurable Linux kernel parameters.

stat filename
Print general info about a file (the contents of the so-called inode).

runlevel
Print the previous and current runlevel.  The output "N5" means: "no previous runlevel" and "5 is the current runlevel".

Runlevel is the mode of operation of Linux. Runlevel can be switched "on the fly" using the command init. For example init 3 (as root) will switch me to runlevel 3. The following runlevels are standard:
     0 - halt (Do NOT set initdefault to this)
     1 - Single user mode
     2 - Multiuser, without NFS (The same as 3, if you do not have networking)
     3 - Full multiuser mode
     4 - unused
     5 - X11
     6 - reboot (Do NOT set initdefault to this)
The system default runlevel is set in the file: /etc/inittab .
<< Previous Page << Previous Page (1/6)       Next Page >> (3/6) Next Page >>

[ Back to Linux Computing | Sections Index ]

 
Scroll Up

   About | Term of Use | Privacy | Adras | Tell a Friend | Advertise  

OSForge News RSS Feed