Quick Reference for Linux Commands

Reply

Join Date: Feb 2002
Posts: 12,035
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Quick Reference for Linux Commands

 
0
  #1
Nov 16th, 2003
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 11:58 am.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 372
Reputation: TheOgre is a jewel in the rough TheOgre is a jewel in the rough TheOgre is a jewel in the rough 
Solved Threads: 6
TheOgre's Avatar
TheOgre TheOgre is offline Offline
Posting Whiz

Re: Quick Reference for Linux Commands

 
0
  #2
Mar 4th, 2004
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
If you spend more on coffee than on IT security, you will be hacked.
What's more, you deserve to be hacked.
-- former White House cybersecurity czar Richard Clarke
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,035
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Quick Reference for Linux Commands

 
0
  #3
Mar 26th, 2004
Hey there. Thanks so much for the corrections. Perhaps you can expand on my list?
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 372
Reputation: TheOgre is a jewel in the rough TheOgre is a jewel in the rough TheOgre is a jewel in the rough 
Solved Threads: 6
TheOgre's Avatar
TheOgre TheOgre is offline Offline
Posting Whiz

Re: Quick Reference for Linux Commands

 
0
  #4
Apr 29th, 2004
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.
If you spend more on coffee than on IT security, you will be hacked.
What's more, you deserve to be hacked.
-- former White House cybersecurity czar Richard Clarke
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 113
Reputation: liliafan is on a distinguished road 
Solved Threads: 2
liliafan's Avatar
liliafan liliafan is offline Offline
Junior Poster

Re: Quick Reference for Linux Commands

 
0
  #5
May 2nd, 2004
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
Application development, webhosting, and much more: www.webcentric-hosting.com
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 468
Reputation: TKS will become famous soon enough TKS will become famous soon enough 
Solved Threads: 18
TKS's Avatar
TKS TKS is offline Offline
Posting Pro in Training

Re: Quick Reference for Linux Commands

 
0
  #6
May 13th, 2004
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.
My Home Away from Home: Yet Another Linux Blog
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 504
Reputation: blud will become famous soon enough blud will become famous soon enough 
Solved Threads: 16
Moderator
Staff Writer
blud blud is offline Offline
Linux Reject

Re: Quick Reference for Linux Commands

 
0
  #7
Jul 5th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1
Reputation: bdm is an unknown quantity at this point 
Solved Threads: 0
bdm bdm is offline Offline
Newbie Poster

Re: Quick Reference for Linux Commands

 
0
  #8
Jul 13th, 2004
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 :]
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,144
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Quick Reference for Linux Commands

 
0
  #9
Nov 11th, 2004
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).
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 11
Reputation: Pmaster is an unknown quantity at this point 
Solved Threads: 0
Pmaster's Avatar
Pmaster Pmaster is offline Offline
Newbie Poster

Re: Quick Reference for Linux Commands

 
0
  #10
Mar 14th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Getting Started and Choosing a Distro Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC