I didn’t find any straight documentation about that, so I decide to write myself one.
Adding an IP alias under dd-wrt console (linux) is simple:
ifconfig br0:1 <ip_address> <netmask>
and is done. Now we should save this command for running on startup. You have 2 choices:
1. web interface
2. shell (ssh or telenet)
1. Web interface
Go to Administration Tab -> Command.
Type the following commands on Command edit box:
#!/bin/ash
PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
ifconfig br0:1 <ip_address> <netmask>
Now press Save Startup
Now you can reboot you router.
2. Shell interface
Log on your router.
and runt the following command:
$ nvram set rc_startup="
#!/bin/ash
PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
ifconfig br0:1 <ip_address> <netmask>
"
$ nvram commit
Success !
Sometimes we need to query, under Linux, Active Directory for users/computers without accessing a remote desktop. We can achieve that with ldapserch. First you should install first ldap-utils. In Debian or Ubuntu just run:
$ sudo apt-get install ldap-utils
The syntax for using ldapsearch:
ldapsearch -x -LLL -h [host] -D [user] -w [password] -b [base DN] -s sub "([filter])" [attribute list]
A simple example
$ ldapsearch -x -LLL -h host.example.com -D user -w password -b"dc=ad,dc=example,dc=com" -s sub "(objectClass=user)" givenName
First you should install smbfs package. Under Debian or Ubuntu is easy, just run:
$ sudo apt-get install smbfs
and apt will install all necessarily dependencies.
Now just mount your windows share
sudo mount -t smbfs -ousername=user //ip_of_your_windows/share /mnt/share
Probably it will ask you the password and after just go in /mnt/share too browse your windows share.
In 99% of my searches I’m using Midnight Commander search function, but sometimes I had servers where I didn’t had mc , so I was forced to search for a file with find. Anyway find is a very powerfull tool and combined with other linux tools like awk, sed, etc can do a lot of things in a very short time.
For example I will try to find my mp3 files from my home folder:
$ find /home/sacx -name '*.mp3'
It will return a list with my mp3 files, but if we want to search for mp3 files with the size bigger than 1MB we will use
$ find /home/sacx -name '*.mp3' -size +100k
or
$ find /home/sacx -name '*.mp3' -size -1000k
if you want to find a file smaller then 10MB.
If you want to search all the files excluding file what start with “Britney” and bigger than 5MB than you should use:
$ find /home/sacx ! -name 'Britney*.mp3' -size +500k
find have a lot of options, but I will let you to find them
Writing shell scripts is not an easy thing if you don’t know the power of awk, sed, grep. Today I will show you how to parse a simple csv file and extract only the needed information, with awk.
For example we have a file with the following content:
red, blue, 123, xxx
red, orange, 321, yyy
blue, orange, 312, zzz
To extract only column 1 and 3 use:
$ awk -F ',' '{print $1", "$3}' /path/to/file
red, 123
red, 321
blue, 312
With -F you can specify the field separator, so you can parse any file what contain separators.