Useful Linux Commands

From Freespire

Jump to: navigation, search
Useful Linux Commands
Home-->Documentation-->Freespire User Manual-->Useful Linux Commands-->Linux Commands < Back     Forward >     


There are a number of commands that give you a wealth of information about your hardware. They can also help you identify problem devices along with the names given to each device by the Linux system.

  • When you switch on your computer lots of text flashes past the screen before you get to the graphical logon. It goes too fast to read, but there is a way to retrieve this. Just type:
 dmesg
  • To view the last few lines of dmesg only - useful when you insert a new device such as a usbstick:
 dmesg | tail

All that text now appears in the terminal and you can read it at your leisure.

  • If you need more detail about the PCI devices such as sound or network cards:
 lspci -v
  • To view USB devices:
 lsusb -v 
  • And what about hard drives? Linux gives the devices it finds when booting names like hda (IDE hard drives) or sda (SATA drives). The partitions on a hard drive are then labelled hda1, hda2, hda3, etc. (or sda1.....). To view the names given to each disk and partition, type:
 fdisk -l
  • To view a list of the modules you have installed:
 lsmod 
  • To view specific modules such as those with the word 'snd' in the name (sound modules):
 lsmod | grep snd
  • Moving, copying, renaming and deleting files and directories can all be performed with a few simple commands. Whether or not you need to enter the full path to the file depends where you are starting from. In Linux your home directory is denoted by the path /home/yourname. So the path to a file saved in this directory would be /home/yourname/file. If you move to this directory before typing a command then you don't need to enter the full path. You can do this by typing:
 cd /home/yourname
  • To check which directory you are currently in type:
 pwd
  • To view the contents of the directory type:
 ls
  • To copy a file type:
 cp /home/yourname/file /home/yourname/directory1

This would copy the file in your home directory to directory1.

  • To move or rename a file type:
 mv file file1

This would rename file to file1

 mv file /path_to_other_directory

This would move the file to another directory.

  • To remove a file type:
 rm file
  • To quickly view the contents of a file:
 cat file

or

 less file

Both commands send the contents of the file to your terminal, but whereas cat sends the entire contents to the terminal less lets you view one page at a time - useful with very long documents.


Linux Commands part 1

Linux Commands part 2

Linux Commands part 3


This page is linked from the Freespire User Manual, please review the Editing Guidelines and follow the wiki Style Guide. Concerns about the topic should reside in the discussion tab.

Personal tools