Misc. Linux Commands

 

Command Parameter Description
cp   Copy files. Syntax: cp filename destination
cp -R Copy files, including files in subdirectories
df   Display empty disk space
du   Display how much disk space files and directories occupies in bytes
dmesg   Displays the hardware information you see during the bootup sequence.
du -h Display how much disk space files and directories occupies in K or MB
find   Find files in the current directory. Syntax: find path filespec
find -iname Find files, ignoring case, by searching all subdirectories. Syntax: find path -iname filespec
find / -iname "*filespec*" will search the whole disc for any files with names including the filespec, ignoring case.
find -name Find files by searching all subdirectories. Syntax: find path -name filespec
find -prune Find files but not directories. Syntax: find path -prune -name filespec
free   Displays your memory usage.
grep -i Search for a textstring in a file, case unsensitive. Syntax: grep -i searchstring filespec
grep -l Search for a textstring in a file, only showing filenames. Syntax: grep -l searchstring filespec
head filename display first ten lines of file. Syntax: head file
kill -1 Restart a process. Syntax: kill -1 processid
kill -9 Brutaly kill a process. Syntax: kill -9 processid
kill -15 Stop a process. Syntax: kill -15 processid
less   Show the content of a file
ls   List files
ls -a Lists all files, including hidden files
ls -l Lists all files using a long format
mkdir   Make a directory
mv   Move files. Syntax: mv filename destination
ps   Show active processes
ps -a Show all users active processes
ps -u Show owner and starttime for the active processes
ps -au show all users' active processes and owners of processes
pwd   Show the name and path to the current directory
rm   Remove files
rm -f Remove files without asking first
rm -r Remove files, including files in subdirectories
rmdir   Remove an empty directory
rmdir -p Remove an empty directory, including empty subdirectories
su   Switch user. Syntax: su user. Just su will ask for the root password
su - Switch to root and get roots environment and paths
tail filename Displays the 10 last lines in a file Syntax: tail file
talk   Chat with another user. Syntax: talk user.
top   Continuously displays your processes, CPU usage and memory usage.
uptime   Tells how long linux has been running
whatis   Tells what a program really does. Syntax: whatis program. Run makewhatis as root to creat database.
whereis   Searches for a file. Syntax: whereis filename

Misc. Floppy Disk commands:

To mount in DOS mode mount -t msdos /dev/fd0 /mnt/floppy
To copy to hard drive cp /mnt/floppy/FILENAME /PATH/FILENAME
To unmount floppy drive umount /mnt/floppy

How to manage user acounts

useradd username -d <home_dir>

passwd username

userdel username

How to mount a Windows share point:

mkdir /mnt/mountpoint

smbmount //server/share /mnt/mountpoint -o username=username

Where:
server = The server's name
share = share point
mountpoint = mount point
username = username with access to the share

From here, you can treat it like any other Linux drive.

To un-mount the above, execute the following command: umount /mnt/mountpoint

Make sure you are not on the mount point when you unmount. Otherwise you will get the following error:
Device or resource busy

Message of the day:

This is a text file that is located in /etc/motd. This will be displayed every time someone logs in.

 

Misc Shell commands

Command line recall: HISTORY

Run Command Number !n (where n=number in history list)
Run Previous Command !!
Run Command Containing String !?string?

It is possible to concatenate multiple commands on one line to be run in a sequential order. To do so, seperate each command with a semi-colon (;). For example: date ; troff -me a_big_document | lpr ; date

To execute a command in the background, end the command with an ampersand (&). for example: troff -me a_big_document | lpr &

to bring a background task to the foreground, use the fg command. For example: fg %xxx where xxx is the process ID. This can be obtained by using the ps command. For example: ps -au returns something like:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
thompsom 7819 0.3 0.5 4036 1368 pts/0
S
16:02 0:00 -bash
root 7849 0.1 0.3 3748 964 pts/0
S
16:02 0:00 su
root 7850 0.7 0.5 4088 1444 pts/0
S
16:02 0:00 bash
root 7853 0.0 0.2 2468 640 pts/0
R
16:02 0:00 ps -au

From this you get the PID for the process.

If a command is stopped it can be started in the background with the following command: bg %xxx where xxx is the PID from above.

When a background task is done, it will display an exit message the next time the Enter key is pressed.