How to find all executable files:
find / -type f -perm -o+rx
This can take quite a while, so you may want to pipe the results to less so you can search in them or instead of root directory to use /bin or /usr/bin.
How to automount USB memory stick devices with user rights.
Edit the line in /etc/group saying “plugdev” with your user name:
plugdev:x:83:root,yourusername
This way every time there is new USB device plugged in the system, you will see a new Icon on your desktop with its name and size. You need to restart udev as root by writing:
sudo /etc/rc.d/rc.udev reload
sudo /etc/rc.d/rc.udev restart
How to change DOS/Windows CR+LF to Unix (dos2unix)
If you don’t have this utility, use the following:
perl -pi -e 's/\r\n/\n/;' DosFilename.txt
How to strip configuration lines from the prompt
Imagine you have a switch configuration example like this:
DUT(config)#system monitor
DUT(config-monitor)#cpu-temperature
DUT(config-cpu-temperature)#log
DUT(config-cpu-temperature)#trap
DUT(config-cpu-temperature)#low-threshold 10
DUT(config-cpu-temperature)#no shutdown
DUT(config)#log ssh-console severity debug
DUT(config)#commit
You need only the configuration lines, without the prompts, so you easily copy&paste them later, when you need to set the switch. Executing this command and pasting results *(or piping them) will strip everything in left of the pound sign (including the sign):
cat | awk -F"#" '{ print $2 }'
or:
cat copied_manual.txt | awk -F"#" '{ print $2 }'
How to decode text to ascii codes for SNMP
Sometimes, walking an SNMP table may show you the following lines:
dot1agCfmMdRowStatus.7.100.111.109.97.105.110.53
This OID line is quite straight forward until the digits. Dot1ag means the standard 802.1ag (OAM CFM) and the status of the maintenance domain. For some reason the remaining text is in ASCII + char length. 7 is char length and the remaining ASCII codes mean “domain5”. I wrote some Perl script to convert strings to dot-digit format for this:
#!/usr/bin/perl -w if (! $ARGV[0]) {die "There are no args";} print $ARGV[0]; print " is equal to "; @ascii_character_numbers = unpack("C*", $ARGV[0]); print scalar(@ascii_character_numbers); foreach (@ascii_character_numbers) { print "."; print $_; } print "\n";
Usage is:
unascii.pl testtest
testtest is equal to 8.116.101.115.116.116.101.115.116
One Response to “Slackware mini How to and various tricks I”
Sorry, the comment form is closed at this time.
In Slackware there is faster (and imho easier way) to change/remove Windows line endings:
fromdos file2
todos file