• Mac OS X,  Mac OS X Server

    Enable SMB Sharing For Specified Users In macOS

    In this article, I looked at enabling SMB and AFP shares via the command line for macOS: Setup the File Sharing Service in macOS 10.13, High Sierra One thing I din’t cover is enabling SMB sharing for a specific user. This is different as passwords need to be stored in an SMB hash. And you can set that hash type with the pwpolicy command. So to do so, we’ll run the command with the -u option so we can supply the username, the -sethashtypes followed by SMB-NT as the hashtype followed by “on” as can be seen here: pwpolicy -u charles.edge -sethashtypes SMB-NT on The interpreter then asks for a…

  • Mac OS X,  Mac OS X Server,  Programming

    25 Time Saving Bash Tips

    Use the following keys to do fun things when typing a command in bash (mostly keybindings): Use the up arrow to run the previous command Continue using the arrow to scroll to commands further in the history Use Control-r to search through your command history Control-w deletes the last word Control-u deletes the line you were typing Control-a moves the cursor to the beginning of the line Control-e moves the cursor to the end of the line Control-l clears the screen Control-b moves the cursor backward by a character Control-u moves the cursor forward by a character Control-_ is an undo “man readline” shows the bash keybindings (ymmv per OS)…

  • Mac OS X,  Ubuntu,  Unix

    cd To The Previous Directory

    The cd command has lots of fun little shortcuts. One I use frequently is the -. The ~ always takes you to your home directory, but using cd – will take you to the last directory you were in. For example, if you do the following on a Mac: cd ~ Then you do .. (which is a shortcut for the directory above the one you’re in): cd .. Then pwd will show that you’re in /Users. But, if you cd to – again: cd - Now you’re back in your home folder. The – expands to OLDPWD. Quick tip. Nothing more to see here.

  • Mac OS X,  Mac OS X Server,  Mac Security,  Ubuntu

    Generating New SSH Keys

    Sometimes when we’re doing work, we end up changing an SSH key. You then access the host using something like this: ssh krypted@10.10.10.10 When accessing the host you then get a warning similar to the following if the key changed: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is aa:bb:cc:dd:ee:ff:00:11:22:33:00:11:22:33:44:55. Please contact your system administrator. Add correct host key in /home/remi/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /home/remi/.ssh/known_hosts:1 In case you…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Ubuntu,  Unix

    Leveraging The Useful Yet Revisionist Bash History

    Not, this article is not about 1984. Nor do I believe there is anything but a revisionist history. Instead, this article is about the history command in OS X (and *nix). The history command is a funny beast. Viewing the manual page for history in OS X nets you a whole lotta’ nothin’ because it’s just going to show you the standard BSD General Commands Manual. But there’s a lot more there than most people use. Let’s take the simplest invocation of the history command. Simply run the command with no options and you’ll get a list of your previously run bash commands: history This would output something that looks…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Mass Deployment

    Automatic Application Termination & Servers

    One of the new features that was introduced in OS X Lion is automatic application termination. This feature stops any applications that haven’t been used for awhile and then when you start the app back up, it fires up using the saved application state. But some processes shouldn’t be stopped. I’ve recently run into 2 cases where I needed to disable automatic termination. To do so is pretty straight forward: defaults write -g NSDisableAutomaticTermination -bool TRUE Once run, read the key back from the global defaults domain to verify it was run correctly: defaults read -g NSDisableAutomaticTermination The output should just be a 1. Provided it’s correct, now test that…

  • Mac OS X

    Opening a Terminal Window From, Well, Terminal

    Terminal is a great application. And we usually use Terminal for editing scripts and invoking things. But what about invoking Terminal from, well, Terminal. For starters, let’s look at opening a Terminal session to the root of the boot volume (aka /): open -a Terminal / The -a option, when used with the open command, allows you to define which application that the item defined in the following position will open in. For example, you could open an XML file in Xcode open -a Xcode /usr/share/postgresql/pg_hba.conf.sample You could then open Terminal by passing other commands into the command. For example, to open a new Terminal window to the current working…

  • Mac OS X

    Backgrounds for Terminal Screens

    Terminal screens can use backgrounds in OS X Lion. To configure these settings, open Terminal and choose Preferences from the Terminal menu. Then click on the Window tab. Use the Image drop down to select Choose. This brings up a browse dialog box that you can use to choose an image. Browse to the image and then click on Open. Choose images that are pretty much all dark or all light as your font should be the opposite color.

  • Mac OS X

    Fixing Color Problems with Ubuntu

    The Terminal application defaults have a problem passing colors with Ubuntu and other types of Linux machines with properly formed .bashrc files. This is because those systems do not know how to interpret the Lion xterm-color256 terminal declaration. The fix is to change this setting to xterm-color. This needs to be done for each Terminal default. Click on each (Basic, Grass, Homebrew, etc) and then click on the Advanced tab. From there, just set the Declare terminal as: to xterm-color and close. This can also be done through the command line. These settings are stored in the com.apple.Terminal.plist per user, in their ~/Library/Preferences. The key for each is in TerminalType,…

  • Mac OS X Server,  Mac Security

    Full Screen Terminal in Lion

    Command-Option-F will send terminal into full screen in OS X Lion (or most any other app for that matter). You can also use the double-arrow button in the top right corner of an application’s title bar to make it full screen. Command-Option-F (or switching to another app or Window that isn’t full screen) will end your full screen session. For any app, you can have one window that is full screen and others that aren’t full screen. Mission Control then shows all the full screen apps at the top of the screen and those that aren’t full screen towards the bottom. I thought I really needed multiple Terminal windows, but…