Linux hints

This post contains some useful Linux hints for a [Windows] dummy like me that often forgets these.

Some shell commands:

chmod a+r file Add read access to file for all owner+group+user instead of just user.
df -h List total disk usage in human readable format.
du -h List disk usage of files/directories in human readable format.
find -name “filename” Find file named “filename” from all subdirectories.
grep -r “needle” . Find text “needle” from all files including subdirectories.
passwd Change password for current user.
tar xvfz file.tar.gz Extract all files from compressed tar gzip file.
tar xvfj file.tar.bz2 Extract all files from compressed tar bzip2 file.

Aliases you may want to add to .bash_aliases:

alias sudo=’sudo env PATH=$PATH’ Forces sudo to use PATH setting from current user instead of root which is the default. This is often useful because it is what you actually want to do instead of using settings from root.

How to mount USB drive:

You can use the following commands to mount USB drive manually to Linux local folder. Replace “sdb1″ with the correct drive, like “sdc”. Replace file system with correct for the USB drive (“vfat” is for FAT32). Replace “/mnt/usb” with any local folder you wish.

mkdir /mnt/usb
mount -t vfat /dev/sdb1 /mnt/usb

How to mount a shared folder from network (Windows server) to Linux computer:

You can use the following command to mount a shared from from Windows server to Linux local folder using the default guest credentials:

mount -t cifs //192.168.0.2/share /media/share -o username=guest,password=

How to assign static IP address to Linux computer:

This is the file to edit for network settings:

cd /etc/network
sudo pico interfaces

Edit the line containing “iface eth0 inet dhcp” and replace it with following (obviously change according to your network):

iface eth0 inet static
  address 192.168.0.7
  netmask 255.255.255.0
  gateway 192.168.0.1
  

Comments are closed.