MicMek's Blog CopTECH

30May/080

Useful Linux Stuff

Here are some useful stuff I need to blog about just in case I need to find them again. Also, some side notes to help me get to know linux better

Copying problem

when you are copying a folder to another place and you want to rename that folder then DONT create that folder first!!
eg.
If I have /home/micmek/testA and I want to copy it to /home/micmek/workingA
If folder workingA already exists then

cp /home/micmek/testA /home/micmek/workingA

will produce

/home/micmek/workingA/testA

but if the folder doesnt exist then the SAME command will produce

/home/micmek/workingA

Links

Symbolic Links vs. Hard Links

Symbolic links point to the file/folder path
Hard links find the Inode that the file is pointing to and points to the same Inode (Data/Content)
Folders have to be symbolic link

ln -s /usr/local/Adobe/bin/acroread acroread

Useful commands

Exiting SSH

Type ~. and you will exit ssh

Boot Log

To find out the log messages from your the booting up of linux ie. all the hardware info type

dmesg

This is useful for mounting purposes too.

Paths

To find out where a file that you commonly execute is in the path structure type the following

whereis cat

Find string in path

To find a certain pattern in a set of files then type

find . | xargs grep 'XXX'

This returns all the files that contain that string

Size of folder

To find the size of a folder type (uses the Disk Usage command)

du -ks PATH

File Permissions

Confusing as it is it's pretty simple

chmod OGO file

Where OGO is a 3 digit number.
O-Owner G-Group O-Other Users
4 = READ || 2 = WRITE || 1 = EXECUTE
So if you want a file to be

Owner Group Others
Read (4) 4 4 4
Write (2) 2 0 0
Execute (1) 1 1 1
Total 7 5 5

Changes owner of file

chown USER file

Mounting

List of mounted devices

To find out what has been mounted type df

df

Mounting & Unmounting

To mount type

mount -t TYPE /dev/DEVICE PATHmount -t vfat /dev/sdb /mnt/usb

To unmount type

umount PATHumount /mnt/usb

Mounting & Unmounting SSH path

To mount a sshfs type

sshfs HOST:PATH TARGETsshfs example.com:/stuff /media/home-pc

To unmount type

fusermount -u PATHfusermount -u /media/home-pc

More Info here:
how to mount a remote ssh file system using sshfs

Services

Services are started and stopped through the following command:

/etc/init.d/SERVICE start/etc/init.d/SERVICE stop

Linux Folder structure

Logs are kept under

/var/logs/XXX

Software is usually installed under

/usr/local

Package

To install a package use

sudo apt-get install XXX

To install a package use

sudo apt-cache search XXX

To find out where a package is installed type

Tagged as: , , No Comments