Commands
From Systerserver
Contents |
Command examples
Generic *nix interaction:
- top/htop and iftop/ntop
- strace -p pid
- lsof -p pid
- which thunderbird (lists the full pathnames of the files that would be executed if the named commands had been run)
- whereis thunderbird (finds the binary, source, and manual page files for a command)
- udatedb, locate
- find -name Aaf_*
- du --max-depth=1
- du -s * |sort -nr (-s = summarise, * is for both files and directories), sort in reverse numerical
- du : disk usage (word of caution is that you should not run this command from the / directory. It will actually display size for every file on the entire Linux harddisk), eg du -a (all), du -h (human readable), http://www.linfo.org/du.html
- df : disk free, eg df -alh
- fdisk -l | grep -i disk
- ls -ldct /lost+found |awk '{print $6, $7}'
- cd -
- sudo !!
- mount |column -t
- watch -n1 df -h -B M /media/disk/ ie how fast data is being copy'd (refreshes every 1 second)
- ssh -X donna@23.42.23.42 xeyes (X forwarding, then start an app on remote server)
- ssh -vD 8080 donna@23.42.23.42 (v = verbose, D = bind address, use any random port number)
- then in firefox you need to set the proxy, ie localhost to use por 8080
- check that your ip adres really has changed by browsing www.myip.dk in ff
- ssh -t user@domain.com ssh user@otherdomain.com
- iptraf instead of iftop
- mtr, cfdisk, hwinfo, nmap, netstat, mc
- for u in dani geert rian victy marlin ester; do sesame.sh -u $u Projects ; done
- but what does the sesame.sh script do??
http://www.pixelbeat.org/cmdline.html
http://www.commandlinefu.com/commands/browse
http://www.oreillynet.com/linux/cmd
Special characters
\ ' " ` < > | ; <Space> <Tab> <Newline> ( ) [ ] ? # $ ^ & * =
Here is the meaning of some of them:
- \ ' " and ' are used for quoting.
- < and > are used for input/output redirection.
- | pipes the output of the command to the left of the pipe symbol "|" to the input of the command on the right of the pipe symbol.
- ; separates multiple commands written on a single line.
- <Space> and <Tab> separate the command words.
- <Newline> completes a command or set of commands.
- ( ) enclose command(s) to be launched in a separate shell (subshell). E.g. ( dir ).
- { } enclose a group of commands to be launched by the current shell. E.g. { dir }. It needs the spaces.
- & causes the preceding command to execute in the background (i.e., asynchronously, as its own separate process) so that the next command does not wait for its completion.
- * when a filename is expected, it matches any filename except those starting with a dot (or any part of a filename, except the initial dot).
- ? when a filename is expected, it matches any single character.
- [ ] when a filename is expected, it maches any single character enclosed inside the pair of [ ].
- && is an "AND" connecting two commands. command1 && command2 will execute command2 only if command1 exits with the exit status 0 (no error). For example: cat file1 && cat file2 will display file2 only if displaying file1 succeeded.
- || is an "OR" connecting two commands. command1 || command2 will execute command2 only if command1 exits with the exit status of non-zero (with an error). For example: cat file1 || cat file2 will display file2 only if displaying file1 didn't succeed.
- = assigns a value to a variable. Example. The command: me=blahblah assigns the value "blahblah" to the variable called "me". I can print the name of the variable using: echo $me
- $ preceeds the name of a variable to be expanded. The variables are either assigned using "=" or are one of the pre-defined variables (which cannot be assigned to):
$0 name of the shell or the shell script being executed.
$# number of the positional parameters to the command
$1 the value of the first positional parameter passed to the command. $2 is the second positional parameter passed to the command. etc. up to $9.
$* expands to all positional parameters passed to the command
$@ expands to all positional parameters passed to the command, but individually quoted when "$@" is used.
See man bash if you really need more.
Backticks are outdated.
- program1 $(program2 $(program3 $(program4)))
- program1 `program2 \`program3 \`program4\`\``
Debian specific
use of root and su -
/sbin staat niet in het pad van de gewone gebruiker
dus voor ifconfig moet je /sbin/ifconfig
of je moet het pad gaan aanpassen
of je moet als root inloggen
Ubuntu specific
by default no root and first user is put in the sudoers file
MediaWiki
add a page to the navigation bar: log in as WikiSysop, goto index.php/MediaWiki:Sidebar
disable anonymous editing: in LocalSettings.php $wgGroupPermissions['*']['edit'] = false;
prevent new user registrations in same file as above: $wgGroupPermissions['*']['createaccount'] = true;
overview index.php/Special:SpecialPages
to see all the pages made (this is how i found spam pages) Special:Allpages
to see everyone that's made an account Special:ListUsers
things to change in the gumax skin:
gumax-article-picture
background image
logo: add $wgLogo = '/path/to/your/logo.png'; to localsettings.php
Networking
1. ifconfig eth0 10.0.0.x
2. route delete default (delete the default gw)
3. route add default gw 10.8.8.8 (need to know that beforehand)
4. nano /etc/resolv.conf (nameserver)
or : echo "nameserver 208.67.220.220" >> /etc/resolv.conf
See also : http://linux-ip.net/html/basic-changing.html
MySQL
- CREATE DATABASE mydb
- GRANT ALL ON mydb.* to db_user@localhost IDENTIFIED BY 'db_passwd';
- FLUSH PRIVILEGES;
- SHOW databases;
- USE mydb;
- mysql -u username -p -h localhost mydb < data.sql; #to import an sql dump
- DROP DATABASE mydb; #to delete a database
- CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;