Skip to content

Instantly share code, notes, and snippets.

@starikovs
Last active August 29, 2015 13:56
Show Gist options
  • Save starikovs/9309861 to your computer and use it in GitHub Desktop.
Save starikovs/9309861 to your computer and use it in GitHub Desktop.
--- ls ---
ls -dl */ (list only directories)
ls -l | grep "^d"
--- copy ---
rsync options source destination (http://cloudtips.org/rsync.html)
rsync -zvr /tmp/helloworld/ /root/message
-z, --compress
-v, --verbose
-r, --recursive
rsync -azv /tmp/helloworld/ /root/message
-a, --archive (archive mode; same as -rlptgoD)
-l, --links (copy symlinks as symlinks)
-p, --perms (preserve permissions)
-t, --times (preserve times)
-g, --group (preserve group)
-o, --owner (preserve owner)
-D (same as --devices --specials)
rsync -azvu /tmp/helloworld/ /root/message
-u, --update (skip files that are newer on the receiver)
rsync -dv /tmp/ /root/remotedirs/
rsync -tdv /tmp/ /root/remotedirs/
-d, --dirs (transfer directories without recursing)
rsync -avz --progress user@host:/tmp/serverdir /tmp/localdir/
--progress (show progress during transfer)
rsync -azv --delete user@host:/tmp/message test2/
--delete (delete extraneous files from dest dirs)
rsync -azv --existing user@host:/tmp/message test2/
--existing (skip creating new files on receiver)
rsync -azvi user@host:/tmp/message test2/
-i, --itemize-changes (output a change-summary for all updates, YXcstpoguax)
rsync -avz --include 'P*' --exclude '*' user@host:/tmp/message test2/
--include=PATTERN (don't exclude files matching PATTERN)
--exclude=PATTERN (exclude files matching PATTERN)
rsync -avz user@host:/tmp/serverdir /tmp/localdir/
rsync -avz user@host:/tmp/serverdir
rsync -avz --max-size='100K' user@host:/tmp/serverdir /tmp/localdir/
-- find --
find ./ -name aaa.php
--- create directories ---
mkdir -p a/b/c
mkdir -p message/{hello,world}
mkdir -p a/b{1,2}/c
mkdir -p a/b{1,2,3/c{1,2}}/d
--- disk usage ---
du -h (disk usage for files in current dir)
du -h f1/ (diska usage for f1/ dir)
du -h -d 1 (disk usage for current dir with 1 depth)
du -hs == du -h -d 0 == du -h --max-depth=0 (current dir, -d 1 - children of dir)
sudo du -h -d 1 /
du -ah --exclude='.git' long-dialog/ (-a - show all)
df -h (disk space of file systems)
df -h / (disk space of specified file system)
df -h ~/note.txt (disk space of file system of file note.txt)
--- add user ---
adduser username
--- user groups ---
usermod -a -G groupname username
--- sudo ---
/etc/sudoers -> must be edited with visudo
export EDITOR=vim (in .bashrc to use vim as a default editor for visudo)
/var/log/secure - sudo log?
--- links ---
ln -s Conf/dircolors .dircolors
--- disk space ---
df -h
--- apache2 ---
sudo apt-get install apache2
/etc/apache2/sites-available/default
AllowOverride All
(http://httpd.apache.org/docs/2.2/howto/auth.html)
htpasswd -c .htpassword user
.htaccess:
AuthType Basic
AuthName "Who are you?"
AuthBasicProvider file
AuthUserFile /var/www/.htpassword
Require valid-user
sudo a2enmod rewrite (a2dismod to disable module)
sudo service apache2 restart
sudo a2ensite sitename
sudo service apache2 reload
--- mysql ---
sudo apt-get install mysql-server
sudo mysql_install_db
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
/usr/bin/mysqladmin -u root -h hostname password 'new-password'
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
sudo /usr/bin/mysql_secure_installation
--- php ---
sudo apt-get install php5 php5-mysql php5-gd
--- ssh ---
/etc/ssh/sshd_conf (man sshd_config)
PermitRootLogin no
Port 22 (change to something else, 25000)
AllowUsers demo
(DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups)
sudo service ssh reload
(Reloading OpenBSD Secure Shell server's configuration: sshd.)
sudo service ssh restart
(Restarting OpenBSD Secure Shell server: sshd.)
/var/log/auth.log (who logged in or sudo)
--- grep ---
http://stackoverflow.com/questions/12516937/grep-but-only-certain-file-extensions
grep -r -i --include \*.css --include \*.php button-new ./
--- redis ---
$ wget http://download.redis.io/releases/redis-2.8.12.tar.gz
$ tar xzf redis-2.8.12.tar.gz
$ cd redis-2.8.12
$ make
(http://redis.io/download)
(-> fail, so lets now:)
sudo apt-get install build-essential
(https://www.digitalocean.com/community/tutorials/how-to-install-and-use-redis)
(jemalloc/jemalloc.h: No such file or directory)
http://blog.gbinghan.com/2012/05/installing-redis-jemallocjemalloch-no.html
$make distclean
$make (OK!!)
Hint: To run 'make test' is a good idea ;)
$make test
cd src && make test
make[1]: Entering directory `/home/vacheslav/src/redis-2.8.12/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/home/vacheslav/src/redis-2.8.12/src'
make: *** [test] Error 2
$sudo apt-get install tcl8.5 (for tests)
$make test
sudo ./install_server.sh (after sudo make install)
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
--- phpredis (https://github.com/nicolasff/phpredis) ---
phpize (sudo apt-get install php5-dev)
(http://www.stableit.ru/2012/11/phpredis-git.html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment