Skip to content

Instantly share code, notes, and snippets.

@xifengzhu
Last active November 7, 2017 06:35
Show Gist options
  • Save xifengzhu/05794be736d65565ef48554437260d57 to your computer and use it in GitHub Desktop.
Save xifengzhu/05794be736d65565ef48554437260d57 to your computer and use it in GitHub Desktop.
程序员开发常用shell 命令

Launch Sublime Text 2 from the Mac OS X Terminal

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

Check process with name

ps aux | grep sidekiq

Upload device id_rsa.pub as a authorized_keys in server

cat ~/.ssh/id_rsa.pub | ssh username@ipAdress 'cat >> .ssh/authorized_keys

Delete file content

echo > /…

Import table to database

mysql -uroot databasename < /Users/xifengzhu/Downloads/drugstores.sql

Dump table from databases

mysqldump  tc_cn_stage translations > translations.sql

Upload file to server

scp translations.sql ubuntu@54.222.170.48:/var/www/tc-china/importDB

Download file from server

scp deploy@120.26.168.207:/home/deploy/cheershub_backend_staging@20161205.sql /Users/${username}/Downloads

Compress file

tar czvf tmp_log.tar tmp_log

Check the server port if open

telnet $domain_name $port
// telnet www.blackluxury.com 443 

Check all the process belong to user

ps -u username

kill all the process belong to user

pkill -u username

kill all the process by name

pkill -f $name

check all the user with password

cat /etc/shadow

forget mysql root password

step 1: stop mysql
/etc/init.d/mysql stop   (service mysqld stop )
step 2: run mysql with mysqld_safe and skip grant table
/usr/bin/mysqld_safe --skip-grant-tables
step 3: login mysql with root
mysql -u root
step 4: update password
use mysql;
update user set password=password("password") where user="root";
flush privileges
exit
step 5: kill musql
ps -A | grep mysql
kill -9 pid
step 6: start mysql
/etc/init.d/mysql start   (service mysqld start)

用特定用户起服务

例如使用redis用户启动redis服务

sudo -u redis redis-server redis.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment