Ubuntu 11.10 Command Line Quick Reference

I’m finding myself searching the web for tons of command line references for Ubuntu, and then forgetting what I looked up a few days later.  The mind is a terrible thing to watch waste.  Well Here is a list of the things I’m finding so that I can get it easily later.

 

Find Files:

find -iname ‘fileiwant.blah’

This is a case insensitive file search in the directory you are in.

 Drive mounting/finding info

sudo fdisk -l

This will display a list of drives and their sizes as well as the important /dev/sdXX

First find the /dev/sdXX that you want to mount, it should look like /dev/sda1 or /dev/sdb1 or something similar.Next you must mount it to a directory using:

sudo mount /dev/sda1 /media/mountdirectory

Insert your dev number where sda1 is and /media/mountdirectory is the location of the directory where you want to mount it.

To find your mount points for already mounted drives simply type:

mount

File Manipulation

cp -Rv filetocopy.file /directorytocopyto/

Copy filetocopy.file to /directorytocopyto/.  It will also copy subdirectories (-R) and -v will show all the files which are copied (verbose).

sudo chmod u+xwr filename

Add execute, write and read to filename for the file owner.  You can change Owner, Group and Other permissions for read, write, and execute.  There is another way and it may be easier if you can understand the numbers.  here is an example: chmod 777 In this example the file would be set to read, write, execute for owner, group and other.

Permission Owner Group Other
Total 7 7 7
Add x 1 w 2 r 4 x 1 w 2 r 4 x 1 w 2 r 4

Unzipping .tgz (tar gz) Files:

Files ending in .tgz are files which have been zipped and tared.  They are the Linux equivalent of .zip files.  To undo them simply type:
tar -xzvf myarchive.tgz
Explanation of options:

x is extract

f FILE is the file to extract

v verbose mode (optional)

z gzip or gunzip mode, necessary for gz files and tgz.

 

Other Links:

https://help.ubuntu.com/community/FilePermissions

https://help.ubuntu.com/community/FileCompression

Leave a Comment

Filed under Ubuntu

Leave a Reply