Some useful command lines

I prefer UI instead of CLI, so every time I need to type in the terminal I forget some command. These are some:

rm -rf mydir

delete an empty or non empty folder (-f : force, -r : recursive)

touch myfilename

create an empty file

cp /dev/null myfilename

empty the document content

wget -m -p -E -k -K -np http://yourdomain.com/subfolder/

grab all the files of current folder and sub-folder

find . -name .DS_Store -type f -delete

delete all .DS_Store (hidden OSX files) starting from “.” (the current directory)

git reset --hard

reset and set the workspace to pull fresh again

git pull

pulls everything from the repo

git config --global credential.helper cache

after that, git will never ask for your user/pass again. But if you have some problem, you can specify your data into repo/.git/config with this:

[user]
    name = you_name
    password = you_password
[credential]
    helper = store
git config --global user.email "you@example.com"
git config --global user.name "Your Name"

with that you can push with this info

git add <file>...

you stage the <file>

git add -A

you stage ALL files (also deleted files)

git commit -m "Add existing file"

you add a comment of the staged files

git push

you push (upload) all the files that staged

Extract an .APK from your Android using the CLI

Sometime we want to analyze certain app that reside in your phone (an Android one), the way to extract this .APK (via the CLI) is using this commands (first you need to connect your android via USB with developer mode activated):

adb shell pm list packages

This list all the packages names of your installed APKs

select your desire package name (in the example: com.sgt.myapp) and run:

adb shell pm path com.sgt.myapp

This command will return a path like: adb pull /data/app/com.sgt.myapp-1.apk. So with this information, run:

adb pull /data/app/com.sgt.myapp-1.apk

Now you have you APK in your computer.

 

Another useful command is:

adb shell dumpsys package com.sgt.myapp | grep versionName

that return the version name

 

“Hidden” options on OSX

Sometime we need to make some tweaks en our OS. Most of the time this options are in “System preferences” via the UI, but other “hidden” options are available from the CLI (Terminal), like:

defaults write com.apple.screencapture type jpg
killall Finder

this command change the default scheenshot format (PNG) to JPG

defaults write com.apple.screencapture disable-shadow -bool true
killall SystemUIServer

to disable drop shadows on a screenshot

defaults write com.apple.finder CreateDesktop false
killall Finder

this one hide all icons in the desktop. To revert this, change to “true”

defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock

add space to the icon’s docks

defaults write com.apple.finder AppleShowAllFiles true;
killall Finder

show hidden files/folders (false to hide)