Ad:
 
You are currently viewing page 1 of this multi-page discussion thread
Nov 16th, 2003
0

Quick Reference for Linux Commands

Expand Post »
Handy Linux User Commands

../ represents one directory higher
cat filename display file contents
cat stuff1 stuff2 > allStuff combine files
cat someStuff >> allStuff append to a file
cd dirName go into the directory dirName
chmod [permission mode] file change the permission of a file (4=read, 2=write, 1=execute for user/group/all)
chown user file change the owner of a file
clear clear the terminal
cp file1 file2 copy file1 to file2
date print current date and time
find someStuff locate a file or directory
finger user get some info about a user
free display some stats about memory usage
ftp hostname connect to an ftp server
gunzip file.gz extract contents of gzipped compressed files
hostname display the hostname of the computer
kill [ID] terminate a process
less file view file in terminal with ability to scroll up and down
ln sourceName destDirectory create symbolic link to a file
locate file locate a file from a database maintained by the computer
login login to the computer
lpr file sends a file to the print spooler
ls list the contents of the current directory
ls directory list the contents of a given directory
man program display manual pages for a program
mkdir directory create a directory
more file view file in terminal with ability to scroll down
mv source target move a file
passwd user change a user's password
pico file open a file in the pico text editor
pwd print the full pathname of the current directory
quota user display the disk quota allocated to a user
rm file delete a file
rmdir directory delete a directory
rm -rf anything forcefully delete something (like a directory, recursively)
sh the standard Unix shell, bash
ssh hostname open an ssh session
su switch to the superuser's (root's) identity
su user switch to another user's identity
tail file print the last 10 lines of a file
telnet hostname open a telnet session
touch file update the access time and last modified time for a file to the current time and date
uname -a print system information
vi file open a file in the vi or vim text editor
who am i gives info about the current user
who -uH gives info and idle times for all users

Handy Linux Sys Admin Commands

halt shuts down the machine
mount /mnt/floppy mounts the floppy fs
mount /mnt/cdrom mounts the cd-rom fs
shutdown -r "now" restarts the machine
umount mountedLocation unmounts a filesystem
update db update file database used by locate command
Last edited by cscgal; Mar 16th, 2006 at 10:58 am.
Administrator
Staff Writer
Reputation Points: 1508
Solved Threads: 138
The Queen of DaniWeb
cscgal is offline Offline
12,542 posts
since Feb 2002
Mar 4th, 2004
0

Re: Quick Reference for Linux Commands

A few minor corrections:

ln sourceName destDirectory create symbolic link to a file
Should be:

ln -s source destination (the -s switch denotes a symbolic link)

sh the standard Unix shell, bash
Should be:

sh is the standard UNIX shell.
bash is the Bourne Again SHell, standard on most Linux systems. UNIX doesn't come with bash, unless it's installed seperately.


Handy Linux Sys Admin Commands

mount /mnt/floppy mounts the floppy fs
Should be:

mount /mnt/floppy mounts the floppy device (if /mnt/floppy is the mountpoint)

mount /mnt/cdrom mounts the cd-rom fs
Should be:

mount /mnt/cdrom mounts the CD-ROM device (if /mnt/cdrom is the mountpoint)

shutdown -r "now" restarts the machine
Should be:

shutdown -r now (no quotes)
or even reboot on some systems

update db update file database used by locate command
Can also be:
updatedb or /usr/libexec/locate.updatedb
Reputation Points: 255
Solved Threads: 6
Posting Whiz
TheOgre is offline Offline
390 posts
since Aug 2003
Mar 26th, 2004
0

Re: Quick Reference for Linux Commands

Hey there. Thanks so much for the corrections. Perhaps you can expand on my list?
Administrator
Staff Writer
Reputation Points: 1508
Solved Threads: 138
The Queen of DaniWeb
cscgal is offline Offline
12,542 posts
since Feb 2002
Apr 29th, 2004
0

Re: Quick Reference for Linux Commands

Sorry I've been away for awhile - work followed by a sunny vacation in Florida, doncha know...

I'll be posting a bunch of stuff next week after I get caught up at the office. Some howto's, cheat sheets, walkthroughs, etc.

If anyone has any requests, drop me a line, and I'll see what I can crank out for you.
Reputation Points: 255
Solved Threads: 6
Posting Whiz
TheOgre is offline Offline
390 posts
since Aug 2003
May 2nd, 2004
0

Re: Quick Reference for Linux Commands

wc -l <file> counts the number of lines in a file
wc -w <file> counts the numbers of words in a file
wc -c <file> counts the number of bytes in a file
wc -m <file> counts the number of characters in file

You can combine with other commands ie:

ls | wc -l will count the number of files in the current directory.
cat /etc/passwd | wc -l will count the number of entries in /etc/passwd
Reputation Points: 83
Solved Threads: 2
Junior Poster
liliafan is offline Offline
113 posts
since Apr 2004
May 13th, 2004
0

Re: Quick Reference for Linux Commands

sometimes you have to specify how to mount a device as well...for instance...I have a second hard disk that is /dev/hdc

In order for me to use it, I have to mount it. In which case I would do the following:

>mount -t reiserfs /dev/hdc /mnt/share.drive (or whatever you want to mount it to in your File sys)

I use reiserfs for my storage drives since I store mostly mp3s, videos, and pics...so sub whatever you'd use in for it.

Also, you'd make changes to your /etc/fstab to automount that same mount you just did the next time you rebooted.
TKS
Reputation Points: 108
Solved Threads: 18
Posting Pro in Training
TKS is offline Offline
470 posts
since Jan 2004
Jul 5th, 2004
0

Re: Quick Reference for Linux Commands

another useful command that can be found is 'netstat' this can be used the same as on windows except with redhat, there are certain flags you can use.

ie.
netstat -a = shows all network traffic
netstat -an =shows all network traffic using numerical ips
netstat -anp = shows all network traffic using numerical ips and what programs they are associated with.
Moderator
Staff Writer
Reputation Points: 165
Solved Threads: 18
Linux Reject
blud is offline Offline
545 posts
since Apr 2004
Jul 13th, 2004
0

Re: Quick Reference for Linux Commands

grep put in stout the line that has the spec word

ps check for all processes that are running

grep + ps in action

#ps aux| grep root

the stdout will be all line that got the wrd root instead

less helpfully command to format the output of a command, like the one above, this stout will be scrollable up/down

more like "less" but scrollable only down

ex.

ls /etc | less

[: sorry for my english :]
bdm
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bdm is offline Offline
1 posts
since Jul 2004
Nov 11th, 2004
0

Re: Quick Reference for Linux Commands

Another handy one is sort

For example a script that shows disk usage per directory sorted largest first:

du $1 > /tmp/du.out
sort -k1nr -odu.sort.out /tmp/du.out
rm /tmp/du.out

-k1nr tells sort to order the file on the first column, numerically, in reverse order

Tried to get it to work without the temp file but couldn't. For some reason sort refused to accept the output from du through a pipe (but maybe I did something wrong).
Team Colleague
Reputation Points: 1484
Solved Threads: 294
Banned
jwenting is offline Offline
7,214 posts
since Nov 2004
Mar 14th, 2005
0

Re: Quick Reference for Linux Commands

Thanks! I am new to RED HAT, and have found this very helpful.
I came to this site for C++ help and yet here I also find help to configure samba,

and help on linux command! I LOVE this site! keep up the good work.
Reputation Points: 12
Solved Threads: 0
Newbie Poster
Pmaster is offline Offline
11 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Getting Started and Choosing a Distro Forum Timeline: Unix/Linux Links
Next Thread in Getting Started and Choosing a Distro Forum Timeline: Linux Suse 10 Wireless





About Us | Contact Us | Advertise | Acceptable Use Policy
Build Custom RSS Feed


Follow us on Twitter


© 2010 DaniWeb® LLC