Home » Featured, Linux

Useful Linux Commands

6 February 2011 No Comment
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Useful Linux CommandsIf you use Linux, you know that Linux commands can be your strength or your downfall. Linux commands are even more vital if you are a Linux Systems Administrator. Without them, you won’t be able to manage Linux systems. It’s either you know it or you don’t.

With that said, how can we help? How would you like to have a list of very, useful Linux commands at your disposal?

Well, you’re in luck. The Linux commands below are available for you in an easy to use page. There is no charge. It is free to use and available anytime you need it. Feel free to come back to this article again and again as a reference for your Linux needs. Enjoy!

The tables below are broken up into different categories for readability. In the table, the column lists the command that should be run on the terminal console of your Linux machine. The second column describes what the command does. The third column describes whether root is required. If root is required, then sudo must accompany the command.

For example, run ”sudo dmidecode -q” to show the hardware system components.

Here are some basic commands that will get you started on learning more about your Linux operating system.

System Information
Command to run Description Requires root?
uname -r show used kernel version No
dmidecode -q show hardware system components (SMBIOS / DMI) Yes
cat /proc/cpuinfo show CPU information No
cat /proc/interrupts show interrupts No
cat /proc/meminfo show memory information No
cat /proc/swaps show file swap No
cat /proc/version show version of the kernel No
cat /proc/net/dev show network adapters statistics No
cat /proc/mounts show mounted file systems No
lspci -tv show PCI devices No
lshw show detailed hardware information Yes
date show system date No
cal 2008 show the calendar for 2008 No

Important commands to know when you need to reboot or shutdown.

Shutdown or Restart a System
Command to run Description Requires root?
shutdown -h now power off the system right now Yes
shutdown -r now restart the system right now Yes
reboot restart the system right now Yes

Learn more about your file system with these commands.

Attaching to a File System
Command to run Description Requires root?
mkdir /mnt/floppy
mount /dev/fd0 /mnt/floppy
attach to a floppy drive Yes
umount /mnt/floppy unattach the floppy drive Yes
mount /dev/cdrom /mnt/cdrom attach to a CD or DVD drive Yes
mkdir /mnt/MyFiles
mount -t smbfs -o username=myuser,password=mypass //MyComputer/MyFiles /mnt/MyFiles
attach to a Windows network share called MyFiles using the provided Windows credentials Yes

Compressing and de-compressing files should be part of your arsenal when working with files.

Archives and Compressed Files
Command to run Description Requires root?
tar cvfz myfile1.tar.gz create an archive zipped file called myfile1.tar.gz No
tar -tf myfile1.tar show the contents of an archive file called myfile1.tar No
tar cvf myfile1.tar file1 file2 dir1 create an archive file containing file1, file2 and directory1 No
gunzip myfile1.gz uncompress a file No
unzip myfile1.zip uncompress a file No
tar -xvf myfile1.tar uncompress the archive file called myfile1.tar No
tar zxvf myfile1.tar.gz uncompress an archive and zipped file called myfile1.tar.gz No

These commands for CDROM come in handy.

CDROM
Command to run Description Requires root?
mkisofs /dev/cdrom > mycd.iso create an ISO image from a CD-ROM No
cdrecord -v dev=/dev/cdrom mycd.iso record data from ISO image mycd.iso to a CD-ROM No
mkdir /mnt/iso
mount -o loop -t iso9660 <filename of ISO image> /mnt/iso
View contents of an ISO image from your hard drive Yes

Networking with interfaces, rather than people, are also important trades to learn.

Networking
Command to run Description Requires root?
ifconfig show configuration of all network interfaces No
route -n show routing table No
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 add static route to reach network 192.168.0.0/16 via the gateway 192.168.1.1 No
host www.somehost.com resolve hostname to IP address No
netstat -tup show all active network connections and their PID No
netstat -tupl show all network services listening on the system and their PID No
iwlist scan show wireless networks No
iwconfig show configuration of all wireless network interfaces No

What packages do you have installed. Learn to install and remove them.

DEB Packages (Debian, Ubuntu)
Command to run Description Requires root?
dpkg -i package_name.deb install or upgrade a Debian package Yes
dpkg -r package_name remove a Debian package from the system Yes
dpkg -l show all Debian packages installed on the system No
dpkg -s package_name show information about a specific package installed on the system No
dpkg -L package_name show list of files provided by a package installed on the system No

Files need to be manipulated. These commands will show you how.

Text Manipulation
Command to run Description Requires root?
cat -n file1 displays content of text file and numbering each row No
tac file1 displays content of text file in reverse order No
tail file1 displays the last 10 lines of a file No
grep “Feb 9” /var/log/messages displays each line in the file that contains the words “Feb 9” No
cat file1 | tr a-z A-Z shows the content of file in upper case letters No

Incoming search terms:

  • tar yes to all
  • linux tar yes to all

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.