Additional useful commands

grep - search for patterns.

greppattern filename

Grep will look for occurrences ofpattern_within the file_filename. grepis an extremely powerful tool. It has hundreds of uses given the large number of options it supports. Check themanpage for more details.

find-allows you to search for a file (wild cards – actually “expressions” permitted). To look for your_XF86Config_file, you might try:

find / -name XF86Config -print

This means "find, starting in the root directory ( / ), by name,_XF86Config_and print the results to the screen". findalso allows you to search by file type or even file times (actually_inode_times).

pwd-prints the present working directory to the screen.

pwd

/home/barry

file -categorizes files based on what they contain, regardless of the name (or extension, if one exists). Compares the file header to the "magic" file in an attempt to ID the file type.For example:

file snapshot01.gif

snapshot01.gif: GIF image data, version 87a, 800 x 600

ps-list of current processes. Gives the process ID number (PID), and the terminal on which the process is running.

ps -axshows all processes (-a), and all processes without an associated terminal (-x).

Output (partial) ofps -**ax**on my system as it is running right now:

PID TTY STAT TIME COMMAND

  1. ? S 0:04 init

  2. ? SW 0:00 [kflushd]

  3. ? SW 0:00 [kupdate] 4 ? SW 0:00 [kpiod]

5 ? SW 0:00 [kswapd]

191 ? S 0:01 /sbin/pump -i eth0

243 ? S 0:00 klogd

  1. tty1 SW 0:00 [login]

  2. tty2 S 0:00 login -- root

  3. tty3 S 0:00 /sbin/mingetty tty3

  4. tty4 S 0:00 /sbin/mingetty tty4

  5. tty5 S 0:00 /sbin/mingetty tty5

  6. tty6 S 0:00 /sbin/mingetty tty6 340 tty1 SW 0:00 [bash]

353 tty1 S 0:00 sh /usr/X11R6/bin/startx

  1. tty1 S 0:00 xinit /etc/X11/xinit/xinitrc -- :0 -auth /home/barry/

  2. ? R 2:04 /etc/X11/X :0 -auth /home/barry/.Xauthority

365 tty1 S 0:05 kwm

368 tty1 S 0:00 kbgndwm

strings-prints out the readable characters from a file. Will print out strings that are at least four characters long (by default)from a file. Useful for looking at data files without the originating program,and searching executables for useful strings, etc.

chmod-changes the permissions on a file. (See the section in this document on permissions).

chown -changes the owner of a file in much the same way as chmod changes the permissions.

chown ral**ph**filename

-rwxrwxr-- 1 ralph user 1643 Jan 19 23:23 filename

chgrp- changes a file’s group attribute. Works the same as chown, but affects the group instead of the owner.

shutdown-this command MUST be used to shutdown the machine and

cleanly exit the system. This is not DOS. Turning off the machine at the prompt is not allowed and can damage your file system (in some cases)3. You can run several different options here (check the man page for many more):

shutdown -r now-will reboot the system now (change to runlevel 6).

shutdown -h now-will halt the system. Ready for power

down (change to runlevel 0).

3. This has become much less of an issue with the newer journaled file systems used by Linux.

results matching ""

    No results matching ""