oligazar
6/15/2017 - 1:07 AM

Terminal

Terminal

Commands

Run app from terminal

sudo /Applications/Android\ Studio\ 3.app/Contents/MacOS/studio

$ esc - show all commands. Press Q to exit.

$ man [command] - manual for the command

$ cd ~ - go to Home, cp - copy, rm - delete

$ pwd - print working directory

$ echo $PATH - what’s in my path

$ ls -a [.folder_name] -l - show files including hidden [in hidden folder]

[права доступа]

$ . filename [arguments] or

$ source filename [arguments] - executes content of of the file passed as argument

Adding a temporary location.

Lives only to the end of the session

$ PATH=<copy what’s in $PATH><new PATH location>

Adding a permanent location

$ nano .bash_profile, or better $ open -e ~/.profile, or $ subl ~/.bash_profile - opens file in an editor

$ export PATH="/usr/local/mysql/bin:$PATH"

.DS_Store - files that Finder creates for itself

etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile - only one is loaded in the order mentioned

$ touch ~/.profile - creates a file if didn’t exist

Permissions

$ chmod - modifies permissions for all users except the file's owner

$ chown - assigns ownership to a specific user

So, to change permissions on a file to allow anyone to access, read, and modify the file, we'd use:

$ sudo chmod 777 path-to-file -r // or 644 for read/access but not change, use -r to modify folder’s permissions

$ ls -la показать файлы (в т.ч скрытые) с правами доступа

Links

Links are aliases - inode name + path name

symbolic links - path name only

hard links - inode name only

Aliases

cmd+alt drag - create alias on the go

cmd+I - to get info

Target of an alias

Aliases (другой, иной, в другой раз) are shortcuts to commands. The terminal defined aliases live only until terminal session ends.

$ alias goto_web="cd ~/Sites" $ alias goto_myP="goto_web; cd myProject"

Links

$ ln -s /path/to/original /path/to/symlink

Users

$ dscl . list /Users — show all users

$ dscl . list /Users | grep -v '_' - excluding daemons

Reset password

// Show/Hide hidden files on mac
// Hold the ‘Option/alt’ key, then right click on the Finder icon in the dock and 
// click Relaunch.
// or just type "showFiles" or "hideFiles"
defaults write com.apple.finder AppleShowAllFiles YES // NO

// Shows a list of installed keys?
Admin ~ $ keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 
Admin ~ $ openssl s_client -showcerts -connect api.amdm.ru:443 </dev/null 2>/dev/null|openssl x509 -outform PEM >mycertfile.pem
Admin ~ $ openssl x509 -outform der -in mycertfile.pem -out mycertfile.crt

// json server
Admin ~ $ json-server db.json
Admin ~ $ json-server generate.js