User:Sam Odio/Linux commands
From BluWiki
Contents
- 1 Cool Linux Commands
- 2 Random Howtos
- 2.1 Automate SSH login w/o passwords
- 2.2 Creating Links
- 2.3 Blogger SFTP access
- 2.4 Search Bash Command Line History
- 2.5 Reboot mac os x from command line
- 2.6 MediaWiki error on installation - max key length is 1024 bytes
- 2.7 Using Screen
- 2.8 Handling a RAID HD failure
- 2.9 Backups
- 2.10 bash tips
- 2.11 Postgres
- 2.12 Mysql
- 2.13 User management
- 2.14 Understanding /proc/meminfo
- 2.15 Important config files
Cool Linux Commands
cat /proc/meminfo free -m
display memory info
dmesg lspci
displays detailed hardware info about machine
tcpdump 'host 10.0.1.22 and ((port http) or (port smtp))' -v
display all http / smtp traffic (realtime)
ps aux
display running applications
scp user@host:./source_file ./destination_file
secure SSH copy
postmap addresses
create addresses.db
rsync -rt ./ root@odioworks.com:/var/www/starvingstartups-com/htdocs
copy files from source dir to destination, ignoring files that haven't changed.
diskutil list
list drives on system (find disk name for volumes)
lsof /dev/disk0s3
Find which applications are using a drive (useful for figuring out why you can't umount a volume)
Random Howtos
Automate SSH login w/o passwords
http://www.linuxproblem.org/art_9.html
Creating Links
Create a symbolic link of an entire directory of files using the (*) wildcard.
ln -sf <system path of files to link>/* <system path of desired new links directory>
Symbolic linking just one file.
ln -sf <system path of file>/<filename> <system path of desired new link directory>
Symbolic linking a directory.
ln -sf <system path to directory> <system path of the desired new link directory>
Blogger SFTP access
Enable blogger sftp access: Change PasswordAuthentication to yes in /etc/ssh/sshd_config
Search Bash Command Line History
history | grep -i "<search string>" !<history number>
Reboot mac os x from command line
osascript -e 'tell application "System Events" to restart'
MediaWiki error on installation - max key length is 1024 bytes
If you get the MySQL error upon installation: failed with error code "Specified key was too long; max key length is 1024 bytes".
Drop(delete) database & execute this line:
CREATE DATABASE `<database name here>` DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci;
Then attempt the installation again.
Using Screen
http://www.linux.com/article.pl?sid=06/08/14/1945249
resume/create a screen:
screen -R
attach to an attached screen:
screen -x
Handling a RAID HD failure
http://gentoo-wiki.com/HOWTO_Gentoo_Install_on_Software_RAID#Misc_RAID_stuff
Once the failed drive is ready to be added back into the array, do so w/ the following command:
mdadm /dev/md1 -a /dev/sdc2
More information on how to replace a failed drive: http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array
Backups
Sync iPhoto from laptop to media center:
rsync -rt ~/Pictures/iPhoto_Library media@192.168.0.112:~/Pictures/
Sync iPhoto from media center to laptop:
rsync -rt media@192.168.0.112:~/Pictures/iPhoto_Library ~/Pictures/
Rdiff backups? http://liquidweather.net/howto/index.php?id=56
bash tips
http://www.deadman.org/bash.html $!:p
end of previous command: !$
common commands: http://cs.clark.edu/~clug/commands.htm
man readline ctrl+w: kill line ctrl+a: beginning of line ctrl+e: end of line
Postgres
Stop postgres: sudo -u postgres pg_ctl stop -D /sw/var/postgresql-8.0/data
Mysql
Start mysql: /sw/share/mysql/mysql.server start
User management
http://www.comptechdoc.org/os/linux/commands/linux_cruserman.html
Understanding /proc/meminfo
http://www.redhat.com/advice/tips/meminfo.html
Important config files
DNS client config:
/etc/resolv.conf
Ethernet config:
/etc/conf.d/net (gentoo) /etc/sysconfig/network-scripts/ifcong-eth0 (centos) /etc/network/interfaces (debian)
View default gateway in debian:
netstat -nr
change:
/sbin/route del default gw 192.168.3.1 /sbin/route add default gw 192.168.3.100
I installed lighttpd & php on debian using this tutorial:
http://www.howtoforge.com/lighttpd_mysql_php_debian_etch