Jean-Do Sifantus

View the Project on GitHub

1 Unix Commands

chflags – to set flags, such as uchg (lock) or hidden, which are often set on the Windows platforms and do not correspond to file modes (chmod) on UNIX/Linux platforms. • ls -lOe – to get a listing of the flags for each file • sudo port select - - set python python 27 (to set a specific version of software like python or perl, which have multiple versions installed) • port note <module> – get note contents for the specified module (not all modules have notes) • listening ports with process:

  • MacOS: sudo lsof -i -n -P | grep TCP
  • Linux: netstat -tulpn

• SCP: secure file copy http://www.hypexr.org/linux_scp_help.php • Listing all users on Linux: awk -F':' '{ print $1}' /etc/passwd

1.1 Mac OS/BDS Commands

scutil – manages system configuration parameters on Mac OS or BDS • mdfind – Spotlight find • dscacheutil – manages dns cache from the command-line • lsof -i | grep LISTEN –> to see socket activity per proces, equivalent to netstat -ab on Windows • sudo lsof -i grep LISTEN —> to see all processes on the system • sips to resize images as in ○ sips -Z 500 screenshot.pngsudo lsof | grep OneNote | grep -v Applications ○ To snoop on a running program's open ports and files • To fix VmWare Fusion slowness with Yosemite from this blog post: https://communities.vmware.com/thread/493294sudo nvram boot-args=debug=0x10 ○ Re-start the Mac ○ Reverse with the following, although you should check whether there are other boot arguments there, which you may not want to remove. § sudo nvram -d boot-args ○ To check if the variable is already there § sudo nvram boot-args

1.2 Git

git config --global core.excludesfile ~/.gitignore_globalgit ls-files --others --exclude-standard --directory

  • list untracked files just like they are listed with the status command

git add `git ls-files -m`

  • add all the modified files to the index, i.e., stage all modified files

git difftool -d one_branch other_branch

  • Uses Diffmerge tool to view the directory differences between two branches
  • git rm --cached `git ls-files -i -X .gitignore`
    • Removes file from the repository based on .gitignore without deleting them form the local file system.

1.3 Mac Startup Repair

1.3.1 Safe re-boot

• Shutdown the system. If you have problems shutting it down, just hold the startup key down for a few seconds until it completely goes down. • Before re-starting, hold down the Command, Shift, and “V" keys together, and while you keep these down press the startup key. The system will start up with a black screen listing all the steps of the booting process. This might take longer than usual, and if it is blocked at some point you may be albe to see an error message providing some information about the problem. Let me know what it is if that happens. • If the system starts correctly eventually. Shut it down again and re-start it normally to see if everything works.

1.3.2 Single-User Mode

• Press the Command and “S” keys together while you press the startup key. • You’ll eventually get a full-screen command line. You’ll have to enter your username and password, the same username and password you use normally to login the system. • Once you’re logged in, type the fsck command as follows: ○ fsck -fy ○ And press the Return key. ○ If that doesn’t work, try /sbin/fsck -fy • Don’t forget the starting slash character. • This will take a while, but it will try to fix all the corrupted sectors and links on your hard drive. • When that completes, type reboot and press the Return key to restart the system.

If that doesn’t work also, you should try resetting the NVRAM/PRAM. Follow this link to get the steps. If this doesn’t work, you may have a problem with the battery on your logic board, which you should be able to get replaced easily at a Mac store.

1.4 Network

1.4.1 Linux Tools

  • nmcli: Redhat Network Manager client, as an alternative to ifconfig.