Linux Tips & Tricks

From WikiWiki

(Redirected from Linux Main)
Jump to: navigation, search
Linux Logo

Misc Linux Tips and Tricks

This is where I will keep various tips and tricks as reminders for me and pointers for others.



Originally Created: August 23, 2007 by Bruce A. Westbrook

Contents


[edit] Network Shares

[edit] How to access network folders without mounting - Gnome GUI

Press 'Alt+F2' (Run Application...) and enter:

smb://[IP_address]/[sharename]

[edit] List Windows shares - command line

List Windows shares:

smbclient -L [IP_address] -U [Windows_username]

[edit] Mount Windows shares - command line

First, you need to install the SMB File System (smbfs) if you haven't already.

sudo apt-get install smbfs

To mount in a Read mode only:

sudo mkdir /mnt/[sharename]
sudo mount //[ip_address]/[share] /mnt/[sharename]/ -o username=[myusername],password=[mypassword]

To mount in a Read/Write mode:

 sudo mkdir /mnt/[sharename]
 sudo mount //[ip_address]/[share] /mnt/[sharename]/ -o username=[myusername],password=[mypassword],dmask=777,fmask=777

[edit] Unmount Windows share - command line

sudo umount /mnt/[sharename]


[edit] Restart Xwindows

Restart the Gnome Desktop Manager by pressing

CTRL+ALT+BACKSPACE

on your keyboard.


[edit] Nmap

[edit] Simple ping sweep

nmap -sP [ip_address]

[edit] Scan single IP address

Single IP address nmap scan, no pinging (P0), verbose (v), determine OS (A), do it fast (T4)

nmap -P0 -v -A -T4 [ip_address]

[edit] Scan multiple IP addresses

Multiple IP address scan from file, no pinging (P0), verbose (v), determine OS (A), do it fast (T4)

nmap -P0 -v -A -T4 -iL [file_with_IP_addresses]


[edit] Netstat

Shows listening programs & port numbers

netstat -l -p --numeric-ports


[edit] iptables

[edit] List rules

List with packet counts for rules (v) & numeric ports instead of names (n)

iptables -vnL

[edit] Clear packet counts

iptables -Z

[edit] List tables

List the NAT/Mangle table

iptables -T nat -vnL


[edit] DNS

[edit] Perform a DNS zone transfer

dig DOMAIN_NAME AXFR

    ** or **

dig @DNS_SERVERr DOMAIN_NAME AXFR

[edit] BIND version

dig @DNS_SERVER txt chaos version.bind

[edit] SOA

DNS Start of Authority record

dig @DNS_SERVER DOMAIN_NAME soa

[edit] GRUB

Fix your GRUB boot loader after it gets hosed from installing Windows on top of Linux (or in my case, when Ghosting to a new laptop hard-drive).

  1. Boot from the Ubuntu LiveCD
  2. Open a terminal window
  3. Application => Accessories => Terminal
    
  4. Run the grub command:
  5. sudo grub
    
  6. Now enter the following command to determine where the boot partition of your linux installation is located:
  7. find /boot/grub/stage1 
    
  8. The above command will return a value that looks like (hdX,Y), where X and Y are numerical values. Type the following to tell GRUB where the boot partition is located and make it the root drive for GRUB to load from:
  9. root (hdX,Y)
    
  10. Now write the updated GRUB stub loader (now with the correct boot partition) to the MBR (first 512 bytes) of the current boot drive:
  11. setup (hd0)
    
  12. Exit GRUB
  13. quit
    
  14. Now cross your fingers and reboot


[edit] CD Copying / Burning

http://unix.freshmeat.net/projects/cdrecord

  1. Copy ISO image from CD:
  2. dd if=[input_device] of=[output-file]
    

    Example:

    dd if=/dev/cdrom of=./xp_pro.iso
    
  3. Mount image to extract files or otherwise verify the ISO image works:
  4. sudo mount -t iso9660 -o ro,loop [iso_file] [mount_point]
    

    Example:

    sudo mkdir /mount
    sudo mkdir /mount/iso
    sudo mount -t iso9660 -o ro,loop ./xp_pro.iso /mount/iso
    
  5. Burn CD from ISO image using cdrecord:
  6. cdrecord -v -data speed=48 [iso_filename]
    

    Example:

    cdrecord -v -data speed=48 ./xp_pro.iso
    

[edit] Checking SSL Versions

At first I tried "sslthingy.sh", which worked at first but then seemed to break on me.

I then found "sslscan" @ http://www.titania.co.uk/sslscan.php To install on Ubuntu, you must first install the libssl-dev libraries, like so:

sudo apt-get install libssl-dev

Then download the sslscan source code from the website above and compile, like so:

tar -zxvf sslscan-1.7
cd sslscan-1.7
make

haha! Of course, then I found that the sslscan is included in the Ubuntu repositories (although not the very latest at the time I wrote this):

sudo apt-get install sslscan
Personal tools
Documentation Center