GENERAL UNIX * Conserver run client: console {TARGET NAME} activate console: ,, sun break to ok (don't work all the time): ,,,<0> quit: ,,<.> files controling the console settings: Solaris 2.6 -- /etc/inittab, /etc/ttydefs Debian 3.0 -- /etc/inittab OpenBSD 3.6 -- /etc/ttys * Getting out of telnet session: shift-control-] * Samba stuff smbstatus -s configfile - reports sshow and how uses shares to set up users to access the samba server (without being able to login to the debian server) add a samba user group to /etc/group: groupadd -g {gid} {groupname} add each samba user with unique UID and samba GID to /etc/passwd: useradd -d /nonexistent -s /bin/false -u {uid} -g {gid} -c "{comment}" {username} set the samba password with smbpasswd: smbpasswd -a {username} use pdbedit to manage the samba backend database if using tdbsam ("passdb backend = tdbsam, guest" in smb.conf): to show all the users in the db: pdbedit -L -v to show same in smbpasswd form: pdbedit -L -w to delete account: pdbedit -x -u {username} to set up samba servers all authenticating to one samba server on the authentication server, where {NETBIOS_NAME} is the name of the client-server: useradd -u {uid} -g {gid} -c "{comment}" -s /sbin/nologin -d /dev/null {NETBIOS_NAME}$ smbpasswd -a -m {NETBIOS_NAME}$ on the client-server: smbpasswd -j {NETBIOS_WORKGROUP} * How much space is being used: du -chs /export/opsy * To copy contents of filesystem cd /dir_to_copy_from find . -depth -print | cpio -pdmvu /dir_to_copy_to (add -l for links?) or: cp -ax / /new-disk or: cd /dir; cp -a `ls -A` /new/dir * SPARC tftpboot stuff to unpack a img file under linux: gunzip -c /tmp/root.img > /tmp/uroot.img # if it's compressed gunzip -c /tmp/vmlinuz > /tmp/uvmlinuz # if it's compressed mke2fs -m0 -b1024 /dev/ram0 4096 # 4MB ramdisk dd if=/tmp/root.img of=/dev/ram0 bs=1024 mount -t ext2 /dev/ram0 /mnt/tmp to create a img file from contents of ramdisk: umount /mnt/tmp dd if=/dev/ram0 of=/tmp/root.img bs=1024 count=4096 /usr/bin/tilo -o /tmp/tftpboot.img /tmp/vmlinuz /tmp/root.img /sbin/blockdev --flushbufs /dev/ram0 # does the same as freeramdisk??? * Mail to send mail: /bin/mail -s "subject line" to@foo.org to2@fah.net Type in the message body. ^d will be prompted for any CC: hit to read mail: /bin/mail lists messages in mailbox. use {num}, "+", or "-" to pick message from list. to read mail: "p" to read mail with more: "more ." to save: "x" to delete: "d {num}" to reply: "r {num}" to list mail: "h" to quit: "q" * POP3 commands: telnet popserver 110 USER name PASS password QUIT - disconnects * Exim stuff: look at the mail queue: mailq try to deliver all messages in the queue: exim4 -qff delete message out of queue: exim4 -Mrm {message-id} * Looking up top level domains: whois -dom * Look up who owns the IP range for a specific IP address: whois -h whois.arin.net {ip-address} * User authentication for apache: http://www.apacheweek.com/features/userauth * VI turning ON and OFF automatic line numbering: set nu /set nonu making vi automatically insert eol set wm=10 SOLARIS * Moving directories that contain links: tar cvf - . | (cd /opt; tar xf -) * Recursively compressing files: find . -type f -exec gzip {} \; * Merge two files separated by \t: pr -m -t -s file1 file2 * List files in file hierachy containing a certain string: grep -l Classes `find . -name '*.htm*' -print` or find . -name '*.htm*' -print | xargs grep -l Classes * Listing open files: Solaris: lsof SunOS: ofiles * Sort files by the disk usage: du -s * | sort -n * Sorting files by size: l -a | sort -n -r -k 5 | more * Finding files without owners/groups and assigning them to root: find / -nouser -print -exec chown root {} \; find / -nogroup -print -exec chgrp root {} \; * Fixing filesystems: finding alternative superblock locations: newfs -Nv /dev/rdsk/c0t3d0s7 fixing: fsck -F ufs -y -o b={backup superblock} /dev/rdsk/c0t3d0s7 * Clearing up an unallocated inode: clri * List of supported disk types: /etc/format.dat * Putting an image on a floppy: dd if=imagefile of=/dev/diskette bs=1440k * NFS statistics: nfsstat * Recompiling windex(manual pages) database: catman -w -M /usr/local/man 1 ^ ^ | | man pages directory section number * Host's id: hostid * Getting the major version of OS: uname -r | cut -f 1 -d . * Sorting running processes by memory usage: ps -el | sort -r -k 10 | less ps -eafl | cut -c45- | sort * Listing processes with full command line: /usr/ucb/bin/ps -ww * priocntl(1) - display or set scheduling parameters of specified process(es) display: priocntl -d {PIDS} set to realtime: priocntl -s -c RT {PIDS} set back to timesharing: priocntl -s -c TS {PIDS} * Listing files opened by a particular process: lsof -p * Listing processes using a port PORT: lsof -i tcp:PORT * Killing processes accessing certain filesystem: fuser -cuk /home/staff * Listing current working directory for a process: /usr/proc/bin/pwdx pid * Directory containing process info utilities : /usr/proc/bin a man-page that describes them: proc * Report virtual memory statistcis: vmstat [interval_in_seconds] * Swap summary: swap -s * Setting a permanent group: newgrp groupname * Display login and logout info about users: last * Modify user's login information in the system: usermod * "Hiding" input: stty -echo * Reboot SunOS style: /usr/ucb/shutdown -r +5 'Message' Solaris style: shutdown -y -i 6 -g 300 'Message' * Look at boottime messages: dmesg * # of processors on the machine: /usr/sbin/psrinfo * Per-processor info about CPUs: mpstat * List dynamic dependencies and shared libraries of an executable: ldd * List installed patches: showrev -p * Listing kernel parameters: sysdef -i * Messing with Sun's input output devices; setting input to keyboard/ttya next time it reboots: ok setenv input-device keybord/ttya setting output to screen/ttya: ok setenv output-device screen/ttya * Talking to Sun's serial line: prompt% kermit C-Kermit> set line /dev/ttya C-Kermit> set speed 9600 C-Kermit> connect * Using kermit for "telnet-like" connection between machines kermit> set host machine-name kermit> connect * Break in Kermit: ^|b * Assigning multiple IPs to a sun: ifconfig le0:1 inet 129.130.12.97 netmask 255.255.255.0 broadcast + or just create (for each logical interface): /etc/hostname.le0:1 * Routing: list static routes: netstat -r[na] status of network interfaces: ifconfig -a stats on network interfaces: netstat -i adding a static route: route add host gateway distance distance is 0 if the gateway is on the same machine disabling routing: /etc/norouter network setup: /etc/rc2.d/ S69inet and S72inetsvc * Booting a very sick Sun machine: ok boot -bs * Rebooting from net: reboot -- net * Modifying EEPROM (NVRAM) parameters after boot: eeprom * Print memory page size: pagesize * Listing ASCII strings compiled into a binary file: strings {filename} * Checking xterm keyboard bindings: stty -a * Resetting stop key (term does not freeze when you hit C-s): stty stop undef * Suspending Solaris box: sys-suspend * Package management on Solaris pkgadd -d {package path} pkgrm pkginfo OPENBSD * Package management on OpenBSD test installing a package: pkg_add -nv {package file} install a package: pkg_add {package file} remove a package: pkg_delete list installed packages: pkg_info * Set up hard drive: fdisk /dev/sdN (where N=disk number) * Partition disk: disklabel /dev/sdN (where N=disk number) * Check unmounted filesystems on Sparc: fsck_ffs -y /dev/rsdNL (where N=disk number and L=partition letter) * To allow root telnet login append "secure" to the ttypN lines in /etc/ttys (where N=1-f) * PF on OpenBSD Check rule syntax with: pfctl -vnf /etc/pf.conf Check rule usage with: pfctl -vs rules Check rule usage with: pfctl -vs nat Check current state with: pfctl -s state Reload with: pfctl -Fa -f /etc/pf.conf NOTE: protocol names must exist in /etc/services, or use the port number! NOTE: on OpenBSD, IP Forwarding is turned off by default, enable by editing /etc/sysctl.conf and uncomment or add the line: net.inet.ip.forwarding=1 REDHAT * Package management on RedHat installing a package (local): rpm -i -v {package file} installing a package (off the net): rpm -i -v -h {URL to package to install beginning with ftp://} where: -i install package -v print useful info about installation -h print 50 hash marks indicating progress useful options: force install new packages over old ones, overwrite packages/overwrite files of other packages percent print percentages as files are unpacked nodep don't do a depenency check before installing a package test don't install, just test - listing all installed packages: rpm -q -a - lising info about an uninstalled package: rpm -q -l -R -p {package.rpm} where: -l list all the files in the package -R list dependencies (packages this one needs) - removing (erasing) an installed package: rpm -e {package} checks removal but does not do anything: rpm -e --test -vv {package} * Force file system check: e2fsck -f /dev/hda7 * Information about locale (local time): /etc/localtime -> /usr/share/zoneinfo/US/Central * Tracing system calls: strace * Command line of a running process: /proc//cmdline * Switching between X and text consoles: X --> text: ctrl + alt + F text --> X: alt + F7 * Setup networking info: /etc/sysconfig/network and /etc/sysconfig/network/ifcfg-eth0 removing redhat boot screen: comment out message=/boot/message in /etc/lilo.conf (don't forget to run lilo) setting text login mode: id:3:initdefault: in /etc/inittab changing file colors: /etc/DIR_COLORS * Setting library path (LD_LIBRARY_PATH substituite) /etc/ld.so.conf * Checking devices on PCI bus cat /proc/pci DEBIAN * Package management on Debian gives you a list of all installed package: dpkg -l to refresh available packages: apt-get update to test removing a package: apt-get -s --purge remove {package-name} to remove a package: apt-get --purge remove {package-name} to test installing a package: apt-get -s install {package-name} to install a package: apt-get install {package-name} to install from particular version: apt-get -t {kernel# | dist name | stable | testing | unstable} install {package-name} to test installing a local package: dpkg --dry-run -i /tmp/rarpd_0.981107-6_i386.deb to install a local package: dpkg -i /tmp/rarpd_0.981107-6_i386.deb * To build a new filesystem cfdisk [/dev/hdX] where X=disk ID mkfs.ext3 -cv [/dev/hdXN] where X=disk ID and N=partition number modify /etc/fstab * Install on software RAID (md) on sarge 3.1 start normal install partition the disks to desired sizes, mark as file system "RAID", don't forget to mark /boot as bootable when finished it will add new disk entries representing the RAID partitions pick the new RAID partitions and pick the file system, mount point, etc. continue install as normal * Check status of md RAIDs: mdadm --detail /dev/mdX ... (where X=number of the RAID) also: cat /proc/partitions and: cat /proc/mdstat * Build a new RAID1 cfdisk [/dev/hdX] where X=disk ID (the partition-types must be set to 0xFD, use fdisk and set the type to "fd") copy the structure from /dev/hdX to /dev/hdY: sfdisk -d /dev/hdX | sfdisk /dev/hdY mdadm -v -C /dev/mdX --level=1 --raid-devices=2 /dev/hdY# /dev/hdY'#' mkfs.ext3 -cv /dev/mdX where X=RAID ID modify /etc/fstab cd /etc/mdadm cp mdadm.conf mdadm.conf.bak echo "DEVICE partitions" > mdadm.conf mdadm --detail --scan >> mdadm.conf mount * Restore a member of a RAID: mdadm --manage /dev/md1 --add /dev/hdc2 * Restore a corrupt member of a RAID: mdadm --zero-superblock /dev/sdb1 mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1 watch -n 3 cat /proc/mdstat cd /etc/mdadm cp mdadm.conf mdadm.conf.bak echo "DEVICE partitions" > mdadm.conf mdadm --detail --scan >> mdadm.conf mkinitrd -o /boot/initrd.img-2.4.27-ct-1-raid * Disable Path MTU Discovery temp: echo 1 >/proc/sys/net/ipv4/ip_no_pmtu_disc permanent: vi /etc/sysctl.conf net.ipv4.ip_no_pmtu_disc = 1