Advertisement
Guest User

disi

a guest
Jan 28th, 2010
843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.34 KB | None | 0 0
  1. 1
  2. ----------------------
  3. udevmonitor - udevmonitor listens to the kernel uevents and events send out by a udev rule
  4. http://man-wiki.net/index.php/8:udevmonitor
  5. prints the devpath of the event to the console. Nice to see how long it takes for a device to become ready (timestamps)
  6. -----------------------
  7. /etc/udev - standard configuration is in /etc/udev/rules.d/50-udev.rules, if you want to create your own rules give it a lower number, so they are applied first
  8. -----------------------
  9. sdparm - change parameters on a SCSI or SATA disk
  10. http://man-wiki.net/index.php/8:sdparm
  11. -----------------------
  12. /etc/issue - read by agetty and printed to stdout BEFORE logon
  13. lots of configuration possible:
  14. \d - Insert the current date.
  15. \o - Insert the domain name of the system.
  16. \r - Insert the release number of the kernel, e.g., 2.4.20.
  17. \s - Insert the system name, the name of the operating system.
  18. \t - Insert the current time.
  19. \u - Insert the number of current users logged in.
  20. v - Insert the version of the OS.
  21. \n - Insert the node name of the machine, also known as the hostname.
  22. \m - Insert the architecture identifier of the machine, e.g., i686
  23. -----------------------
  24. /etc/issue.net - same as /etc/issue but used for users who connect via telnet
  25. -----------------------
  26. /etc/motd - read by agetty and printed to stdout AFTER logon
  27. -----------------------
  28. wall - sends a text to the terminal of all logged on users, limited to 20 lines, finished by EOF (ctrl+d)
  29. http://man-wiki.net/index.php/1:wall
  30. -----------------------
  31. 2
  32. -----------------------
  33. /usr/src/linux - symlink to the /usr/src/linux-2.6.33-whatever folder which contains the kernel source code
  34. -----------------------
  35. /usr/src/linux/Documentation - contains all the kernel documentation to modules and how linux works
  36. -----------------------
  37. zImage - compressed kernel image (gzip was used to compress) after compiling the kernel (make) it is saved to the folder /usr/src/linux/arch/i386/boot/
  38. -----------------------
  39. bzImage - compressed kernel image (bzip2 was used to compress)
  40. -----------------------
  41. mkinitrd - reads the /etc/modprobe.conf (former /etc/modules.conf) and creates an initrd file that contains all the needed kernel modules for the system to run (e.g. raid modules). The initrd file is is loaded by the boot loader BEFORE it loads the kernel (e.g. lilo or grub) and provides the ramdisk to the kernel.
  42. -----------------------
  43. mkinitramfs - creates a ramdisk as the root filesystem after the kernel is loaded and provides certain files in it. Configuration files are in /etc/initramfs-tools/ it can/will also hold modules which are needed by the kernel during boot.
  44. -----------------------
  45. make targets (config, xconfig, menuconfig, oldconfig, mrproper/clean, zImage, bzImage, modules, modules_install)
  46. -----------------------
  47. patch - applies diff files to existing files
  48. http://man-wiki.net/index.php/1:patch
  49. patching the kernel manually:
  50. make a backup of the current kernel
  51. # cd /usr/src
  52. # tar cvfz linux_old.tgz linux
  53.  
  54. zcat extracts the "diff" file, patch -p0 applies the differences and tee places a copy of the output into patch.out
  55. # cd /usr/src
  56. # zcat patch-2.0.1.gz | patch -p0 2>&1 | tee patch.out
  57.  
  58. search for failed patches:
  59. # find . -name '*.rej' -print
  60. output is something like:
  61. previously applied patch detected: Assume -R?
  62.  
  63. now you can get new sources or use your backup, those version problem cannot occur using patch-kernel
  64.  
  65. patch and options:
  66. -b - make a backup before applying the diff file (if the file didn't exist before an empty file is created)
  67. -E - remove empty files
  68. -f - force ... well
  69. -o - define the output file instead of using the original
  70. -r=xxx - puts rejected patches into this file instead of xxx.rej
  71. -s - suppress output instead of errors
  72. -p - define how much of the path should be cut in the patch (just -p is the same as p0, but to be POSIX you should always put a number there)
  73. example, supposing the file name in the patch file was
  74. /u/howard/src/blurfl/blurfl.c
  75. setting -p0 gives the entire file name unmodified, -p1 gives
  76. u/howard/src/blurfl/blurfl.c
  77. without the leading slash, -p4 gives
  78. blurfl/blurfl.c
  79.  
  80. patch-kernel is part of the kernel sources
  81. it search in the current directory for patches with a higher version than the actual kernel and applies them automatically
  82. default location: /usr/src/linux/scripts
  83.  
  84. -R - "tries" to reverse the previous applied patch...
  85. cd /usr/src
  86. zcat patch-2.4.22.gz | patch -p0 -R
  87. ---------------------
  88. lsmod - reads the /proc/modules and sends it to stdout, this also shows how many users use the module
  89.  
  90. rmmod - removes a module from memory, only works if not used, useful option -w waits until module is not used anymore and then removes it
  91.  
  92. insmod - loads a module into the kernel
  93.  
  94. modprobe:
  95. adds/removes modules in the kernel
  96. reads the modules.dep file to see which additional modules are needed for this module
  97.  
  98. -r you can specify more than one module at a time to be loaded but only one to be removed (-r), if you remove a module, it will also try to remove it's dependencies, if not used
  99. -f - force
  100. -l - lists all modules matching a given wildcard
  101. -n - --dry-run it does everything but actual inserting/deleting the module to check
  102.  
  103. ----------------------
  104. /usr/src/linux/.config - contains the kernel configuration, this file can be edited directly
  105. ----------------------
  106. /lib/modules/kernel-version/* - contains the compiled modules for the kernel
  107. ----------------------
  108. /boot/* - contains the kernel, initramfs, initrd and probably grub bootloader files
  109. ----------------------
  110. autofs
  111. http://man-wiki.net/index.php/5:autofs
  112. /etc/auto.master - contains the mount options (times etc.) for mount points defined in /etc/auto.whatever
  113. /etc/auto.[dir] - contains mountpoints, it can lookup /etc/fstab for options
  114. ----------------------
  115. mkisofs - creates an ISO image that can be burned to a CD/DVD
  116. http://man-wiki.net/index.php/8:mkisofs
  117. ----------------------
  118. dd - converts and copies files
  119. -if= - input file (can be a device)
  120. -of= - output file (can be a device)
  121. -ibs= - bytes it reads at a time
  122. -obs= - bytes it writes at a time
  123. -bs= - block size, sets ibs and obs at a time
  124.  
  125. the sizes can be set with the trailing format:
  126. xM M, c 1, w 2, b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.
  127. ----------------------
  128. mke2fs - creates an ext2 filesystem on a device
  129. http://man-wiki.net/index.php/8:mke2fs
  130. -j - enables journaling (ext3 filesystem)
  131. ----------------------
  132. mdadm - used to configure the raid devices on the system
  133. http://man-wiki.net/index.php/8:mdadm
  134.  
  135. mdadm [mode] <raiddevice> [options] <component-devices>
  136.  
  137. modes:
  138. -A assemble - put parts of a previously created array together, it can search for settings automatically
  139. -C create - creates a new array with superblocks written to each device
  140. -F follow/monitor - raid0 never has something to monitor
  141. -G grow - change number of active devices in a radi1, grow/shrink raid 1/4/5/6 arrays
  142. manage - remove or add devices to an array
  143. misc - everything else
  144.  
  145. examples:
  146. assemble and start all arrways listed in /etc/mdadm.conf
  147. mdadm --assemble --scan
  148. shutdown all arrays that can be stopped, not currently in use
  149. mdadm --stop --scan
  150. Create /dev/md0 as a RAID1 array consisting of /dev/hda1 and /dev/hdc1
  151. mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hd[ac]1
  152.  
  153. info about the current arrays:
  154. /proc/mdstat
  155. info about current configuration:
  156. /etc/mdadm.conf
  157. ----------------------
  158. fdisk - tool to alter the partition table
  159. http://man-wiki.net/index.php/8:fdisk
  160. ----------------------
  161. BIND:
  162.  
  163. named it self is a daemon for dns, it reads the config and has only a few options
  164. -4 - use only ipv4
  165. -6 - user only ipv6
  166. -c - configfile
  167. -f - run in foreground
  168. -n - number of threads to be created per cpu, default one per cpu
  169. -p - port to listen to, default 53
  170.  
  171. /etc/named.conf - contains the settings for the named server
  172. /var/named/ - contains settings for the different zones, caches etc. this differs from version 8/9 or distribution
  173.  
  174. has general options and zone related options
  175. example:
  176. options {
  177. directory "/var/lib/named";
  178. forwarders { 10.0.0.1; };
  179. notify no;
  180. };
  181.  
  182. zone "localhost" in {
  183. type master;
  184. file "localhost.zone";
  185. };
  186.  
  187. zone "0.0.127.in-addr.arpa" in {
  188. type master;
  189. file "127.0.0.zone";
  190. };
  191.  
  192. zone "." in {
  193. type hint;
  194. file "root.hint";
  195. };
  196.  
  197. options related entries:
  198.  
  199. directory - where are the zonefiles
  200. forwarders - who should I ask to resolve hostnames (probably your ISP DNS)
  201. forward first/only; - should I first ask my ISP, before I contact the root server?
  202. listen-on port 53 { 127.0.0.1; ip-address; }; - which interfact to listen on for incoming requests
  203. listen-on-v6 port 53 { any/none; }; - ipv6 yes or no
  204. allow-query { 127.0.0.1; net; }; - who is allowed to query the server, net is like 192.168.0/24
  205. allow-transfer { ! *; }; - don't allow zone transfers from anywhere, default is set to allow
  206. statistic-interval 0; - interval in minutes between logs in /var/log/messages
  207. cleaning-interval 720; - interval in minutes between clear of the cache, creates entry in /var/log/messages
  208. interface-interval - interval between check for new network devices to listen on, default 60min
  209. notify no; - no other nameservers are notified about zone changes
  210.  
  211. zone related entries:
  212.  
  213. type - master or slave, if slave, then you have to give the master or slave to listen to
  214. zone "andere-domain.de" in {
  215. type slave;
  216. file "slave/andere-domain.zone";
  217. masters { 10.0.0.1; };
  218. };
  219.  
  220. allow-update { ! *; }; - zone updates are not allowed from extern, default is no
  221. ---------------------
  222. resource record formats
  223. format: <name> [<ttl>] [<class>] <type> <rdata>
  224. name - domainname of the object/host
  225. ttl - time to live in seconds
  226. class - optional, could be IN=the Internet class, CH=the Chaos class, HS=the Hesiod class, ANY=Wildcard
  227. type:
  228. A - most common entry is the ipv4 address of a host
  229. AAAA - ipv6 address of a host
  230. CNAME - an alias for an A host
  231. MX - mail exchange server
  232. NS - nameserver
  233. PTR - reverse mapping, for IP address to a host, does not work with CNAME
  234. SOA - start of authority, define global parameters for the zone, only one per zone
  235. SRV - a service, does not work with CNAME
  236. TXT - free text
  237. ---------------------
  238. /usr/sbin/rndc - control utility for BIND 9 (BIND 8 uses ndc), does not yet support all functionalty ndc did
  239. http://man-wiki.net/index.php/8:rndc
  240. -c - config file, default /etc/rndc.conf
  241. -k - key file (it uses a shared secret to authenticate), default /etc/rndc.key
  242. -s - server name/ip address
  243. -p - port, default 953
  244. ---------------------
  245. kill - terminates running processes on the system
  246. http://man-wiki.net/index.php/1:kill
  247. if nothing is pecified it uses the TERM signal, which asks the process to stop nicely
  248. signals:
  249. SIGINT 2 Term Interrupt from keyboard
  250. SIGQUIT 3 Core Quit from keyboard
  251. SIGILL 4 Core Illegal Instruction
  252. SIGABRT 6 Core Abort signal from abort(3)
  253. SIGFPE 8 Core Floating point exception
  254. SIGKILL 9 Term Kill signal
  255. SIGSEGV 11 Core Invalid memory reference
  256. SIGPIPE 13 Term Broken pipe: write to pipe with no readers
  257. SIGALRM 14 Term Timer signal from alarm(2)
  258. SIGTERM 15 Term Termination signal
  259. ---------------------
  260. dig - linux replacement for nslookup
  261. http://man-wiki.net/index.php/1:dig
  262. dig @server name type
  263. server - server to query, if none given it takes /etc/resolv.conf
  264. name - name to query
  265. type - type of record to look up e.g. A, CNAME, MX, NS etc.
  266. ---------------------
  267. nslookup - old dns lookup tool
  268. http://man-wiki.net/index.php/1:nslookup
  269. ---------------------
  270. host - another dns lookup tool
  271. http://man-wiki.net/index.php/1:host
  272. ---------------------
  273. shadow password suite:
  274.  
  275. provides password up to 16 characters (default 8)
  276.  
  277. /etc/passwd (writeable by root and readable by users):
  278. username:passwd(replaced by "x" if shadowed):UID:GID:full_name:directory:shell
  279. e.g.
  280. username:x:503:100:Full Name:/home/username:/bin/sh
  281.  
  282. /etc/shadow (only readable and writeable by root):
  283. username:passwd:last:may:must:warn:expire:disable:reserved
  284. e.g.
  285. username:Npge08pfz4wuk:9479:0:10000::::
  286.  
  287. /etc/login.defs
  288. it sets default parameters for new created users, like:
  289. CHFN_AUTH - authentication required before you can change the users info (chfn) or his shell (chsh) (boolean yes/no) - doesn't affect superuser
  290. GID_MIN and GID_MAX - Group ID min max e.g. 1000 and 10000
  291. UID_MIN and UID_MAX - User ID min max e.g. 1000 and 10000
  292. MAIL_DIR - spool directory e.g. /var/spool/mail
  293. PASS_MAX_DAYS and PASS_MIN_DAYS - only applies to new created users (if not set -1 disabled)
  294. PASS_WARN_AGE - only - only applies to new created users (if not set -1 disabled)
  295. UMASK - default umask for users (if not set it defaults to 022)
  296. USERDEL_CMD - command to execute if a user gets deleted (delete at/cron/print jobs, mail, home etc.)
  297.  
  298. if you just install it afterwards, you must convert your password from /etc/passwd:
  299. cd /etc
  300. /usr/sbin/pwconv
  301. pwconv takes your /etc/passwd file and strips out the fields to create two files: /etc/npasswd and /etc/nshadow
  302. move /etc/npasswd and /etc/nshadow to /etc/passwd and /etc/shadow to replace the old ones
  303. -----------------------
  304. DNSSEC - singature for zones on the dns server
  305.  
  306. master dns server encrypts the hash of the zone using his private key
  307. all the slaves can use the public key to decrypt the hash and make sure the file is not changed
  308.  
  309. to renew a key on the master, you have to check the ttl (usually 24h)
  310. the rule is to apply the key, wait double time ttl (48h) and then use the new key to encrypt the hash
  311. be very carefully while you do this, it could shut down whole domains
  312.  
  313. problems are with current routers, they expect a reply to dns query as udp, if the udp package contains the signature, the package is too big and might get blocked.
  314.  
  315. ICANN controls the root zones and around july 2010 all the root zones should have a DNSSec siganture.
  316.  
  317. You need at least BIND 9.4.2
  318.  
  319. generate a key for a zone:
  320. DNSsec-keygen -a RSASHA1 -b1024 -e -n ZONE example1.com
  321.  
  322. the created key file needs to be attached to the zonefile:
  323. cat K*.key >> example1.com
  324.  
  325. sign the zonefile:
  326. DNSsec-signzone -s now+0 -e now+2419200 -o example1.com -k Kexample1.com.+005+15342 example1.com \ Kexample1.com.+005+63344
  327.  
  328. change the entry in /etc/named.conf for the zone as follows:
  329. file "/etc/bind/example1.com.signed";
  330. DNSsec-enable yes;
  331. ------------------------
  332. 3
  333. ------------------------
  334. * /lib/modules/kernel-version/modules.dep
  335. * module configuration files in /etc
  336. * /proc/sys/kernel/
  337. ------------------------
  338. depmod - depmod creates a list of module dependencies, by reading each module under /lib/modules/kernel-version
  339. http://man-wiki.net/index.php/8:depmodand determining what symbols it exports, and what symbols it needs. By default this list is written to modules.dep in the same directory
  340. ------------------------
  341. modinfo - shows information about a certain module, like modprobe --show-depends, but it doesn't know anything
  342. http://man-wiki.net/index.php/8:modinfoabout /etc/modprobe.conf or aliases, it gets the info direct from the module
  343. ------------------------
  344. uname - prints information about the current system
  345. http://man-wiki.net/index.php/2:uname
  346. -a - all information
  347. -i - name of the platform
  348. -n - hostname
  349. -s - name of the operating system
  350. ------------------------
  351. fsck (fsck.*) - checks filesystems and optionally repais them
  352. http://man-wiki.net/index.php/8:fsck
  353. common exit codes:
  354. 0 - No errors
  355. 1 - File system errors corrected
  356. 2 - System should be rebooted
  357.  
  358. -t - specifies the filesystem type otherwise fsck will lookup /etc/fstab, if not found it uses ext2
  359. -A - check all filesystems in /etc/fstab
  360. -N - show what would be done, don't do it
  361. -R - skip root filesystem
  362. -V - be verbose
  363. -a - automatically repair errors without question
  364. -n - don't repair but report, doesn't work for fsck.reiserfs
  365. -r - interactively repair the filesystem
  366. ------------------------
  367. badblocks - checks a device for bad blocks
  368. http://man-wiki.net/index.php/8:badblocks
  369. -o file - creates a list of bad blocks in the file, which can be used with mke2fs or e2fsck to bypass them
  370. ------------------------
  371. mkfs (mkfs.*) - create a filesystem on a device
  372. http://man-wiki.net/index.php/8:mkfs
  373. -t fstype - type of filesystem to be created
  374. -c - check with badblocks before creating the filesystem
  375. -l file - use the file (from badblocks) to avoid bad blocks
  376. ------------------------
  377. dumpe2fs - shows superblock information about a filesystem
  378. http://man-wiki.net/index.php/8:dumpe2fs
  379. -b - shows blocks that are defined as bad on the filesystem
  380. ------------------------
  381. debugfs, debugreiserfs - technically all you can do with a filesystem, delete, move, rename, inodes etc.
  382. ------------------------
  383. tune2fs - change settings on an ext2 ext3 filesystem
  384. http://man-wiki.net/index.php/8:tune2fs
  385. important options:
  386. -c counts between file system checks via fsck integer (common is between 20-100)
  387. -i intervall between file system checks, can be (d)ay (m)onth (w)eeks 0 disables this feature
  388. -e changes behaviour of the kernel, if something goes wrong
  389. continue - work ahead and ignore the error
  390. remount-ro - remount the partition as read only
  391. panic - produce a kernel panic
  392. -j attach a journal to the existing ext2 filesystem (kernel needs support for ext3), the options for the journal are set automatically
  393. -J define the journal options like size=journal size in the filesystem or device=external journal on another device
  394. -l show superblock content
  395. -L set the label for for volume e.g. MYSUPERDISK (maximum of 16 characters)
  396. -U set the UUID (Universally Unique IDentifier) - clear (delete), random (generate a random one), time (generate one based on time)
  397. ------------------------
  398. mkswap - create a swap filesystem on a partition/file
  399. http://man-wiki.net/index.php/8:mkswap
  400. creating a swapfile:
  401. # dd if=/dev/zero of=swapfile bs=1024 count=65536
  402. # mkswap swapfile
  403. ------------------------
  404. xfs filesystem is mostly used if large files need to be saved (best performance)
  405. http://xfs.org/index.php/Main_Page
  406. xfs can be easily expanded using the defeult fs commands (CANNOT BE SHRINKED, good with lvm)
  407.  
  408. xfs_info - The filesystem geometry is printed, and argument checking is performed
  409. xfs_growfs - expands an existing XFS filesystem (filesystem has to be mounted)
  410. xfs_check - checks whether an XFS filesystem is consistent. Needs to be defragmented from time to time.
  411. xfs_repair - repairs corrupt or damaged XFS filesystems (needs to be unmounted)
  412. xfs_db - gives access to the filesystem internals interactivly
  413.  
  414. check fragmentation:
  415. xfs_db -r /dev/sda3
  416. xfs_db> frag
  417. actual 62504, ideal 440, fragmentation factor 99.30%
  418. xfs_db>
  419. ------------------------
  420. LVM:
  421. The Logical Volume Manager binds physical volumes together in a volume group with logical volumes :)
  422.  
  423. use one or more normal dos partition and change the type via fdisk to 8e
  424.  
  425. now you create physical volumes on it via
  426. pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
  427. commands pvremove, pvdisplay, pvmove
  428.  
  429. now we create the volume group via
  430. vgcreate fileserver /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
  431. creates either /dev/mapper/fileserver or /dev/fileserver
  432. commands: vgdisplay, vgscan, vgrename, vgremove, vgextend
  433.  
  434. now we create a logical volume via
  435. lvcreate �name share �size 40G fileserver
  436. creates either /dev/mapper/fileserver/share or /dev/fileserver/share
  437. commands: lvdisplay, lvscan, lvrename, lvremove, lvextend, lvreduce
  438.  
  439. very interesting is, that you can create the LVM over a raid array like:
  440. pvcreate /dev/md0 /dev/md1
  441. ------------------------
  442. mount - hangs filesystems into an exiting folder on the system and creates an entry in /etc/mtab
  443. http://man-wiki.net/index.php/8:mount
  444. if no option is given, it shows the content of /etc/mtab
  445. -a - mounts everything in /etc/fstab
  446. -n - mount without /etc/mtab entry
  447. -r - mount read only
  448. -w - mount read/write
  449. -U - mount UUID
  450. -t - filesystem type or use blkid library, or read /etc/filesystems and /proc/filesystems to probe the superblock
  451. -o - options, seperated by comma
  452. auto - mount via -a
  453. defaults - rw,suid,dev,exec,auto,nouser,async
  454. exec - permit execution of binaries
  455. noatime - no access times are recorded on the FS for files (speed)
  456. nodiratime - no access times are recorded on the FS for directories (speed)
  457. noauto - needs to be especially mounted (not during boot)
  458. noexec - deny execution of binaries
  459. nosuid - no suid or guid allowed
  460. nouser - only root can mount it, default
  461. remount - remount the device
  462. ro - read only
  463. rw - read/write
  464. user - normal users can mount and unmount the device
  465. users - all users can mount and unmount the device
  466. bind - remount the device/subsystem at another place, will be available at both mountpoints
  467. move - umount and mount it somewhere else
  468. loop - can mount images of CD/floppy etc. it uses /dev/loop to mount the file
  469. ------------------------
  470. umount - detaches a filesystem and removes the entry in /etc/mtab
  471. http://man-wiki.net/index.php/2:umount
  472. -n - don't touch /etc/mtab
  473. -d - if the device was a loop device it frees up the /dev/loop
  474. -a - all filesystems in /etc/mtab get detached
  475. -f - force
  476. -l - lazy umount, this will remove any reference of the mounted filesystem (cannot be accessed anymore), it detaches it as soon as it is no longer used, especially helpful with network filesystems (cifs/nfs)
  477. ------------------------
  478. /sbin/route - manipulate the kernel routing table
  479. http://man-wiki.net/index.php/8:route
  480. it is normally used to add or delete static routes to certain networks
  481. without argument it displays information about the current routing table
  482. add - add a route
  483. del - removes a route
  484. common examples:
  485. route add default gw mango-gw
  486. route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
  487. route add -net 10.0.0.0 netmask 255.0.0.0 reject
  488.  
  489. files it queries/alters:
  490. /proc/net/ipv6_route
  491. /proc/net/route
  492. /proc/net/rt_cache
  493. ------------------------
  494. /sbin/ifconfig - displays/alters network interfaces
  495. http://man-wiki.net/index.php/8:ifconfig
  496. without option it displays current ACTIVE interfaces and it's settings
  497. up - activates an interface
  498. down - deactivates an interface
  499.  
  500. common example for gigabit network:
  501. ifconfig eth0 up 192.168.1.12/24 media type 1000baseT
  502. ------------------------
  503. /sbin/ip - show / manipulate routing, devices, policy routing and tunnels
  504. http://linux.die.net/man/8/ip
  505. ------------------------
  506. /usr/sbin/arp - manipulate the system ARP cache
  507. -a host - displays the arp cache for a certain hostname
  508. -d host - deletes the cache for a certain host
  509. -i if - shows entries that match the interface
  510. -s host hw_addr - add an entry for a host
  511. -f file - add antries from a file, default /etc/ethers
  512. ------------------------
  513. /sbin/iwconfig - configure a wireless network interface (currently cannot WPA)
  514. http://man-wiki.net/index.php/8:iwconfig
  515. without option it shows information from /proc/net/wireless
  516. essid - define the ESSID it should connect to
  517. mode - Set the operating mode of the device
  518. -Ad-Hoc - network composed of only one cell and without Access Point
  519. -Managed - node connects to a network composed of many Access Points, with roaming
  520. -Master - the node is the synchronisation master or acts as an Access Point
  521. -Repeater - the node forwards packets between other wireless nodes
  522. -Secondary - the node acts as a backup master/repeater
  523. -Monitor - the node is not associated with any cell and passively monitor all packets on the frequency
  524. -Auto - usually managed
  525. freq - set the frequency
  526. channel - set the channel
  527. ap - set up as access point
  528. key/enc - set the WEP encryption key
  529. ------------------------
  530. /sbin/iwlist - scan for wireless networks in range
  531. http://man-wiki.net/index.php/8:iwlist
  532. iwlist wlan0 scanning - lists available networks in range with default settings
  533. freq - change frequency
  534. channel - change channel
  535. ------------------------
  536. /bin/sh - shell, the standard command language interpreter
  537. ------------------------
  538. cpio - copies files into and out from a cpio archive.
  539. http://man-wiki.net/index.php/1:cpio
  540. -i - copy in
  541. -o - copy out
  542. -p - copy pass
  543. example:
  544. ls | cpio -oc > ../newfile - writes the files listed by ls into the archive newfile
  545. cat newfile | cpio -icd "memo/a1" "memo/b* " - checks the output of cat for teh files that match and extracts them
  546. ------------------------
  547. tar - used to archive files to a file or tape drive
  548. http://man-wiki.net/index.php/1:tar
  549. -t - list content of an archive
  550. -x - extract a file
  551. -c - create an archive
  552. -d - diff - compare files in an archive
  553. -r - append files to an archive
  554. -u - update files in an archive
  555. -A - append a tar archive to an exisitng one
  556. -j - use bzip2
  557. -z - use gzip
  558. -Z - use compress
  559. -v - be verbose
  560. -p - preserve the permissions on a file
  561. --exclude - exclude files in a directory
  562. ------------------------
  563. /dev/st* and /dev/nst - SCSI tape drives
  564. ------------------------
  565. mt - tape control program... well
  566. http://man-wiki.net/index.php/1:mt
  567. ------------------------
  568. rsync - Synchronize file trees across local disks, directories or across a network
  569. http://man-wiki.net/index.php/1:rsync-2006.11.06
  570. syntax:
  571. rsync [option] machine:folder machine:folder
  572. http://ss64.com/bash/rsync.html
  573. ------------------------
  574. 4
  575. ------------------------
  576. boot -> bash
  577.  
  578. BIOS -> bootloader -> kernel -> init (PID 1)
  579. we have kernel space memory and user space memory, init is the first process running in user space memory on the system
  580. init becomes the parent of all following processes with PID 1
  581.  
  582. runlevels control which scripts should be started by init
  583. commonly is SysV, which was choosen to be easier than the BSD system
  584.  
  585. default folder for those scripts /etc/rc.d/init.d or /etc/init.d
  586.  
  587. You can create symbolic links to the scripts to assign them to certain runlevels
  588. symbolic links are in /etc/rc.d/rc0-6.d/ or /etc/rc0-6.d/ on some systems
  589. assign httpd (apache) to start in runlevel 3
  590. ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S85httpd
  591. assign httpd (apache) to stop in runlevel 3
  592. ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/K15httpd
  593. S=Start K=Kill, while the number indicates the order of the scripts in the runlevel folder
  594.  
  595. some distribution related scripts to handle those links are:
  596. chkconfig - Redhat based distributions
  597. --level - which runlevel should be changed
  598. --add name - adds a new script to the runlevels defined in the script itself as default
  599. --del name - removes a script from all runlevels
  600. --list - list of all scripts for all runlevels and status
  601. chkconfig --level 345 dhcpcd off - turns off dhcpcd for runlevels 3, 4 and 5
  602.  
  603. I think Redhat has also something like: service dhcpcd start/stop/restart
  604.  
  605. ALL OTHER DISTRIBUTIONS :D
  606. update-rc - Debian based distributions
  607. update-rc name remove
  608. update-rc name boot/defaults
  609. update-rc name start/stop
  610.  
  611. rc-update - Gentoo based distributions
  612. rc-update add/del dhcpcd default
  613. rc-update show
  614.  
  615. the runlevels were given names and those names are defined in /etc/inittab
  616. 0 Halt (system shutdown)
  617. 1 Single User mode (no network)
  618. 2 not used, could be used for special stuff
  619. 3 Multiuser Mode (networking)
  620. 4 not used, could be used for special stuff
  621. 5 Multiuser Mode with X (networking)
  622. 6 Reboot
  623.  
  624. typical /etc/inittab:
  625. # default runlevel
  626. id:3:initdefault:
  627. # first script to run after boot
  628. si:S:sysinit:/etc/rc.d/rc.sysinit
  629. # start /etc/rc.d/rc with defined runlevel as argument
  630. 10:0:wait:/etc/rc.d/rc 0
  631. 11:1:wait:/etc/rc.d/rc 1
  632. 12:1:wait:/etc/rc.d/rc 2
  633. 13:3:wait:/etc/rc.d/rc 3
  634. 14:4:wait:/etc/rc.d/rc 4
  635. 15:5:wait:/etc/rc.d/rc 5
  636. 16:6:wait:/etc/rc.d/rc 6
  637. # what to run on ctrl+alt+del
  638. ca::ctrlaltdel:/sbin/shutdown -t3 -rf now
  639. # start agetty on all virtal consoles 1-6
  640. c1:12345:respawn:/sbin/agetty 38400 tty1
  641. c2:12345:respawn:/sbin/agetty 38400 tty2
  642. c3:45:respawn:/sbin/agetty 38400 tty3
  643. c4:45:respawn:/sbin/agetty 38400 tty4
  644. c5:45:respawn:/sbin/agetty 38400 tty5
  645. c6:45:respawn:/sbin/agetty 38400 tty6
  646.  
  647. code:runlevel:action:program
  648. as you can see, in runlevel 1, 2 and 3 are only 2 consoles ready with agetty waiting for the login
  649.  
  650. in /etc/inittab is one line, which defines the default runlevel, the system would boot into
  651. id:5:initdefault:
  652.  
  653. very last script to run after all scripts for the runlevel were started (doesn't exist on Debian based systems):
  654. /etc/rc.d/rc.local
  655.  
  656. to switch between runlevels, you can use the telinit command
  657.  
  658. after agetty (or whatever you use) is started:
  659. it opens a tty port, prompts for a login name and invokes the /bin/login command.
  660.  
  661. /bin/login checks the password, checks mail, print queue, prints motd (if exists) and date/time
  662. in the end it starts the program defined in /etc/passwd as login shell e.g. /bin/bash
  663.  
  664. /bin/bash executes the script /etc/profile and ~/.bash_profile (if defined in /etc/profile)
  665. shows the command prompt and waits for input
  666. ---------------------------
  667. /etc/fstab - defines mount points
  668. device/uuid/label mount point filesystem options(mount) dump fsck order
  669. /dev/sda1 /boot ext2 noauto,noatime 1 2
  670.  
  671. labels can be defined via e2label or during mke2fs, this makes the system more robust if you have to change drives
  672. ---------------------------
  673. /proc/mounts - contains information about mounted filesystems, nearly the same as /etc/mtab
  674. ---------------------------
  675. sync - flushes filesystem buffers and writes all outstanding changes to disk
  676. http://man-wiki.net/index.php/1:sync
  677. ---------------------------
  678. /bin/netstat - shows a lot of information about the network subsystem
  679. http://man-wiki.net/index.php/8:netstat
  680. no option and it shows all open sockets
  681. -r - show routing table as route
  682. -g - show ipv4 and ipv6 groups (e.g. lo and eth0 etc.)
  683. -s - show statistic about every protocol
  684. -c - show continuously every second update
  685. -e and -v - more info
  686. -p - show the program PID that uses the socket
  687. -l - show only listening sockets
  688. ----------------------------
  689. /bin/ping - uses ICMP as part of IP protocol to request an ECHO from a host
  690. http://man-wiki.net/index.php/8:ping
  691. -b - ping broadcast (e.g. 192.168.1.255)
  692. -c 5 - stops ping after 5 packages were received
  693. -i - interval between pings (default 1 sec)
  694. -I eth0 - set interface to use (rquired for ipv6)
  695. -s - define packagesize (default is 56 byte + 8 byte ICMP header = 64 byte)
  696. -t - set the IP ttl
  697. ----------------------------
  698. /usr/sbin/tcpdump - dump traffic on the network (sniffer)
  699. http://man-wiki.net/index.php/1:tcpdump
  700. print all traffic from or to host sundown:
  701. tcpdump host sundown
  702. print all traffice between helios and hot or ace:
  703. tcpdump host helios and \( hot or ace \)
  704. print all ip packages from or to ace, except of from to helios:
  705. tcpdump ip host ace and not helios
  706. ----------------------------
  707. /usr/sbin/lsof
  708. http://man-wiki.net/index.php/8:lsof
  709. reads kernel memory and provides output about open files of the following types:
  710. regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.)
  711.  
  712. the output is not nice and can be parsed to another program for formatting
  713.  
  714. files it searches for information:
  715. /dev/kmem kernel virtual memory device
  716. /dev/mem physical memory device
  717. /dev/swap system paging device
  718.  
  719. no option lists all open files of all processes (nasty)
  720. -a AND to all filters entered example: -a -U -ufoo (all UNIX sockets AND that belong to user foo) default is OR used for the filters
  721. -i lists open files on internet connections [46][protocol][@hostname|hostaddr][:service|port] example: -i4tcp@somehost:ssl or -i4tcp@10.0.0.5:22
  722. -l doesn't resolve userids to usernames (might speed up the process a little)
  723. -m specify the kernel memory file, default /dev/kmem or /dev/mem you can also specify a kernel crash dump file to analyse what was open at this time
  724. +M enable portmapper information default is disabled
  725. -n doesn't resolve IP addesses to hostnames (might speed up the process a little)
  726. -N list open NFS files
  727. -p open files for a process ID e.g. "123,234,567"
  728. -r endless repeat mode
  729. +r repeat until no open files are listed or end signal received
  730. -s show size of files at all times (even for sockets, which don't really have one, it shows the kernel buffer size instead)
  731. -u specify the user e.g. -ubob,234,123,tom
  732. -U list UNIX domain sockets
  733. -v display the version of the lsof program
  734. +w disabled warnings
  735. -w enable warnings
  736.  
  737. listing output:
  738. COMMAND:PID:PPID:PGID:USER:FD:TYPE:FILE-ADDR:FCT:FILE-FLAG:NODE-ID:DEVICE:SIZE, SIZE/OFF, or OFFSET:NODE:NAME
  739.  
  740. COMMAND - the first 9 characters of the command that was executed
  741. PID - process ID that owns the file
  742. PPID - parent process ID that owns the process
  743. PGID - process group ID that owns the file
  744. USER - the user ID that owns the process
  745. FD - file descripter - what kind of file is it and if it has read, write or u for read+write access
  746. TYPE - what kind of node is associated with the file e.g. ipv4 ipv6 or nfs etc.etc.
  747. SIZE - size of the file or buffer size or off
  748. NODE - inode on nfs share or tcp/udp etc.
  749. NAME - actual name of the file on the filesystem or mountpoint
  750.  
  751. some examples from the man pages:
  752. To list all files using any protocol on ports 513, 514, or 515 of host wonderland.cc.purdue.edu, use:
  753. lsof -i @wonderland.cc.purdue.edu:513-515
  754. To list all open files for login name ``abe'', or user ID 1234, or process 456, or process 123, or process 789, use:
  755. lsof -p 456,123,789 -u 1234,abe
  756. To list all open files on device /dev/hd4, use:
  757. lsof /dev/hd4
  758. To send a SIGHUP to the processes that have /u/abe/bar open, use:
  759. kill -HUP `lsof -t /u/abe/bar`
  760. To ignore the device cache file, use:
  761. lsof -Di
  762. ----------------------------
  763. /usr/bin/nc - netcat makes connection, listens, using different ports, TCP/UDP, ipv4 and ipv6
  764. http://man-wiki.net/index.php/1:netcat
  765. -4 - use ipv4
  766. -6 - use ipv6
  767. -i - interval between lines being received/send
  768. -l -k - listen rather than send packages -k means keep listening after a connection is closed
  769. -n - no dns lookup or hostname resolution
  770. -p - start a connection on a specified port
  771. -r - use random ports
  772. -s - specify the source IP address (fake)
  773. -t - do telnet session (not full features, no session because no DO and WILL)
  774. -u - use UDP instead of default TCP
  775. -v - be verbose
  776. -w - specify timeout in seconds
  777. -x address:port - use proxy server
  778. -z - scan for listening daemons on the system
  779.  
  780. example:
  781. listen on port 1234 on console tty1
  782. nc -l -p 1234
  783. connect to localhost on port 1234 from console tty2
  784. nc 127.0.0.1 1234
  785. you are now connected, the input on one console is transfered to the other and vice versa (like chat)
  786.  
  787. send an email to localhost (typed into console):
  788. nc localhost 25 << EOF
  789. HELO host.example.com
  790. MAIL FROM: <user@host.example.com>
  791. RCPT TO: <user2@host.example.com>
  792. DATA
  793. Body of email.
  794. .
  795. QUIT
  796. EOF
  797.  
  798. portscanning using netcat:
  799. nc -z host.example.com 20-30
  800. Connection to host.example.com 22 port [tcp/ssh] succeeded!
  801. Connection to host.example.com 25 port [tcp/smtp] succeeded!
  802. ---------------------------
  803. ip - show / manipulate routing, devices, policy routing and tunnels
  804. ---------------------------
  805. /etc/openvpn/ - contains the server/client configuration files
  806. http://man-wiki.net/index.php/8:openvpn
  807.  
  808. typical server.ovpn:
  809. # port to listen on
  810. port 1194
  811. # TCP or UDP?
  812. proto udp
  813. mode server
  814. tls-server
  815. # device to use, could be tap or tun, depends on the kernel modules
  816. dev tap
  817. # server IP on the tap device
  818. ifconfig 192.168.100.1 255.255.255.0
  819. ifconfig-pool 192.168.100.2 192.168.100.9
  820. # where are the certificates
  821. ca /etc/ssl/vpn-ca.pem
  822. cert /etc/ssl/certs/server_cert.pem
  823. key /etc/ssl/private/server_key.pem
  824. #Diffie-Hellmann parameter ?!?!?
  825. dh /etc/ssl/dh2048.pem
  826. # use the same address on next session?
  827. #ifconfig-pool-persist ipp.txt
  828. # change the routing table and dns on clients to use the local network?
  829. #push "route 10.0.0.0 255.0.0.0"
  830. #push "dhcp-option DNS 192.168.1.xyz"
  831. #push "redirect-gateway"
  832. #push "route 0.0.0.0 0.0.0.0"
  833. # authentication method
  834. auth SHA1
  835. # encryption used
  836. cipher aes-256-cbc
  837. # compression used
  838. comp-lzo
  839. # set permissions
  840. user nobody
  841. group nogroup
  842. persist-key
  843. persist-tun
  844. # logging level: 0-7
  845. verb 7
  846.  
  847. test the configuration before it is actual applied
  848. openvpn --config /etc/openvpn/Server.ovpn
  849. start the server using the configuration (usually the distribution has start-stop-daemons for that)
  850. openvpn /etc/openvpn/Server.ovpn
  851.  
  852. openvpn - server and client executeable for ssl vpn connections
  853. bridge:
  854. - application can handle it better, since the machine is in only one network
  855. - easy to set up
  856. routing:
  857. - routing tables for each subnet
  858. - better scaleability (security)
  859. - MTU tuning
  860.  
  861. initial setup:
  862. /usr/local/openvpn_as/bin/ovpn-init
  863. you need to use a user that exists on the system for the first login (usually root)
  864. this script configures interfaces and ports
  865. default admin port: 943 (e.g. http://myserver:943)
  866. default vpn port: 443
  867.  
  868. start/configure the client on linux:
  869. openvpn --config client.ovpn (where client.OVPN is free chooseable to identify the server)
  870. openvpn cannot change the clients dns configuration on unix/linux systems
  871.  
  872. most of the settings are actual done on the webinterface
  873. support for PAM, RADIUS, LDAP for authentication
  874. openvpn can route, so the vpn clients can be routed to a certain network on the server
  875. ---------------------------
  876. nmap - network monitoring tool
  877. http://man-wiki.net/index.php/1:nmap
  878. this is the hollywood hacker program number one :)
  879. -A - be aggressive (nearly always used)
  880. -n - no DNS resolution
  881. -O - enable OS detection
  882. -p - sepcify the port range to scan
  883. -P - ping options
  884. -P0 - scans a network for hosts, e.g. if Class B address is given, it scans 65,536 hosts
  885. -PS [portlist] - TCP SYN flag port scan, if no port is given it uses port 80
  886. -PA [portlist] - TCP ACK ping
  887. -PU [portlist] - UDP ping
  888. -PR - arp ping!!!, common usage to check if the fault is in TCP/IP or Ethernet
  889. -s - most of those options are for package manipulation (e.g. -sX is Xmas scan :D it sets FIN, PSH and URG flags)
  890. -sO - protocol scan (what protocols are supported on the target system)
  891. -sS - SYN scan
  892. -sT - TCP scan
  893. -sU - UDP scan
  894. ---------------------------
  895. wireshark - network package analyser (sniffer)
  896. http://man-wiki.net/index.php/1:wireshark
  897. some CLI commands that come with Wireshark package (http://www.wireshark.org/docs/man-pages/):
  898. capinfos - Prints information about capture files
  899. dumpcap - Dump network traffic
  900. editcap - Edit and/or translate the format of capture files
  901. idl2wrs - CORBA IDL to Wireshark Plugin Generator
  902. mergecap - Merges two or more capture files into one
  903. rawshark - Dump and analyze raw libpcap data
  904. text2pcap - Generate a capture file from an ASCII hexdump of packets
  905. tshark - Dump and analyze network traffic
  906. wireshark-filter - Wireshark filter syntax and reference
  907. wireshark - Interactively dump and analyze network traffic
  908. ---------------------------
  909. /usr/src - Source code
  910. For systems based on glibc, there are no specific guidelines for this directory :)
  911. ---------------------------
  912. configure, make, make install
  913. configure alters the target in the makefile to your needs, if you don't need certain features in a program or need features that are not enabled per default you can use the configure script to turn them off/on or change parameters. Then you start make to build the binary and if the target is available you can use make install to copy the compiled binarys/libraries to it's default location in the system.
  914. Since configure scripts are totally different from one to another and it depends on the author of the program, the source usually comes with a README file or you can look directly into the Makefile to see what you can change via ./configure
  915. not much else to say here :(
  916. ---------------------------
  917. 5
  918. ---------------------------
  919. /etc/network - debian specific network configurations are stored here
  920. many graphical configuration tools save in here as well
  921. example from Ubuntu wiki (/etc/network/interfaces):
  922. ## Loopback interface
  923. auto lo
  924. iface lo inet loopback
  925.  
  926. ## LAN interface
  927. auto eth0
  928. iface eth0 inet static
  929. address 192.168.0.97
  930. netmask 255.255.255.0
  931. gateway 192.168.0.1
  932.  
  933. ## WLAN interface
  934. auto ath0
  935. iface ath0 inet dhcp
  936. wpa-driver wext
  937. wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  938.  
  939. RedHat:
  940. /etc/sysconfig/network � Specifies routing and host information for all network interfaces.
  941. routes:
  942. /etc/sysconfig/network-scripts/ifcfg-<interface-name>
  943. ---------------------------
  944. System log files
  945. http://man-wiki.net/index.php/5:syslog.conf
  946. ---------------------------
  947. /etc/resolv.conf - contains a list of nameservers/domains to use
  948. nameserver - IP/hostname of the nameserver, if more than one, it is queried in order
  949. domain - domainname to query, if not given it uses the hostname e.g. desktop.local
  950. search [domainname] - again domainname to search for
  951. ---------------------------
  952. /etc/hosts - contains static ip address resolvers
  953. example:
  954. ip-address computername.domain alias1 alias2
  955. 127.0.0.1 myserver.mydomain.com ns.mydomain.com mx.mydomain.com
  956. ---------------------------
  957. /etc/hosts.allow & /etc/hosts.deny - restricts access to services on the machine
  958. example /etc/hosts.allow:
  959. # <service list> : <host list> [: command]
  960. #
  961. # everybody has access to mail
  962. in.smtpd: ALL
  963.  
  964. # access to telnet and ftp is restricted to users on the same domain
  965. #
  966. in.telnetd, ftpd: LOCAL, tuxhausen.outside.all
  967.  
  968. # everybody can finger, but root gets an email
  969. #
  970. in.fingerd: ALL: (finger @%h | mail -s "finger from %h" root)
  971. ----------------------------
  972. /etc/hostname | /etc/HOSTNAME - name of the computer without domain
  973. ----------------------------
  974. hostname - show or set the system's host name (changes entry in /etc/hostname)
  975. dnsdomainname - show the system's DNS domain name (changes entry in /etc/hosts)
  976. domainname - show or set the system's NIS/YP domain name (changes the NIS domainname)
  977. nisdomainname - show or set system's NIS/YP domain name
  978. ypdomainname - show or set the system's NIS/YP domain name
  979. ----------------------------
  980. /usr/sbin/traceroute - uses ICMP as part of the IP protocol to trace the route to a host, showing the "hops"
  981. http://man-wiki.net/index.php/1:traceroute
  982. -4 - use ipv4
  983. -6 - use ipv6
  984. -g - specify gateway to use
  985. -i - specify interface to use
  986. -n - no dns lookup
  987. ----------------------------
  988. /bin/dmesg - prints the kernel ring buffer
  989. http://man-wiki.net/index.php/8:dmesg
  990. checks /proc/kmsg
  991. shows all the boot hardware setup
  992. -c - clear wing buffer after printing to the console
  993. -nlevel - define filter (-n 1) only shows panic messages
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement