Fullscreen Command Line Mode (OS X -NoGUI)

Discussion in 'PowerPC Macs' started by AphoticD, Feb 24, 2018.

  1. AphoticD, Feb 24, 2018
    Last edited: Feb 24, 2018

    AphoticD macrumors 68000

    AphoticD

    Joined:
    Feb 17, 2017
    Location:
    Australia
    #1
    I'm not sure how well known this little trick is, but if you're looking to run a regular installation of OS X as a GUI-less CLI, with none of the bells and whistles of Aqua, Cocoa and the rest of it, then you can run the Darwin/BSD underpinnings standalone. This can result in a huge improvement on energy efficiency and as you can imagine, zero load on your Mac's GPU, reducing heat and fan operation.

    If you're a power user who finds themselves working in Terminal more often than not (I'm looking at you @Lastic), then you could essentially double the battery life on a PowerBook, iBook, MacBook, etc and run the BSD command line in fullscreen with the graphical OS X essentially disabled.

    1. First, go to System Preferences > Accounts (Or Users and Groups on more recent systems)
    2. Click the Lock symbol and enter your admin password.
    3. Go to Login Options and change the "Display login window as:" option to "Name and password".
    4. Log out of your account (Cmd-Shift-Q).
    5. At the login screen, in the Name field, enter: >console and hit return.
    6. The screen will turn black as the graphical loginwindow service shuts down and then you'll be greeted with a familiar login prompt for full-services access to your account via the CLI.
    7. Enter your login name and password as usual to get started.

    As this is only a single "Virtual terminal", the best method of creating additional VTs (or tabs as in Terminal app terminology), is to use the 'screen' command. 'man screen' for documentation, but essentially;

    $ screen <enter>

    To create a new VT / screen, hit Ctrl-a, c
    To cycle through your active screens, hit Ctrl-a, n
    To select a specific screen, hit Ctrl-a, <0-9>
    To leave 'screen' and return to a single-prompt, close all VT shells with 'exit'

    There is also a split screen view for displaying more than one terminal at once.

    Once you've mastered 'screen', install a text-based web browser such as links (sudo port install links), to start using your GUI-less OS X for web browsing, IRC, Vi, Emacs, etc.

    Wifi connectivity will pick up and automatically be configured for the last connected network from your OS X session. Any services you have enabled via your account's Sharing tab (in System Preferences), such as File Sharing, will still run, so to conserve more resources, be sure to switch these off beforehand (or use 'launchctl' to enable/disable services)

    With all the services disabled, an entire loaded OS, such as Tiger, will operate in as little as 50MB of active memory.

    Sleep via closing the lid works fine, or you can tell the computer to sleep with 'pmset sleepnow'.

    To return to your usual OS X interface, enter 'exit' at the prompt and you'll be returned to the graphical login window.

    -AphoticD

    :apple:

    IMG_2725.jpg
     
  2. Dronecatcher macrumors 68030

    Dronecatcher

    Joined:
    Jun 17, 2014
    Location:
    Lincolnshire, UK
  3. Lastic macrumors 6502a

    Joined:
    Mar 19, 2016
    Location:
    North of the HellHole
    #3
    Very good post , I was already aware of this but it is worth a mention.

    I came home late , it's past midnight so I will pick up in the morning on things I might have forgotten.

    A few more things :

    on my MBpR >console results in CLI in the maximum resolution aka tiny fonts, since the GPU kexts aren't loaded you cannot change the resolution , there are some scripts floating around but they only work when Aqua is running.

    tmux can also be used instead of screen but you must install it via Macports.

    You can detach a running screen session by using Ctrl A d and later reattach by using screen -list to list your screen sessions and screen -RR to attach to the last one .

    At work we use this method (de-attaching) a lot when running a process in loop which needs to keep running before your ssh session times out or to avoid the process being killed when you logout from the machine.

    In OpenBSD on PPC the brightness and volume keys also work in CLI only mode but in OS X not.

    But no fear here is :

    Volume Control https://coderwall.com/p/22p0ja/set-get-osx-volume-mute-from-the-command-line
    Brightness https://github.com/nriley/brightness ( OS X 10.6 but there must be a working 10.5 commit )

    Might look into getting the Function Keys working to correspond to the Volume and Brightness actions.

    OS X has a builtin command-line music player called afplay but it doesn't have a lot of controls and keeps running until you kill
    it with CTRL-C ( you can run it in background by adding & to it , fg to call it back to the foreground )

    Macports does have mpg123 which is a bit fancier and there are other CLI only players around.

    You can turn on your Airport WiFi using :

    sudo networksetup -setairportpower on

    You can get the status of your connected WiFi SSID by using :

    sudo airport -I

    You can check your battery status using :

    sudo pmset -g batt

    Any USB disk you insert , has to be manually mounted :

    diskutil list to see your disk number and partition

    diskutil mount /dev/diskxsy (x being the disk number , y being the partition number)

    diskutil eject /Volumes/partition-name

    I tried using this CLI method to get more RAM free to run text-only VM's in QEMU but never got any decent results so went back to Aqua .

    Going to bed now , expect an DevOps post with ansible , vagrant and Qemu tomorrow and will reflect on more usefull things for the >console mode .
     
  4. AphoticD thread starter macrumors 68000

    AphoticD

    Joined:
    Feb 17, 2017
    Location:
    Australia
    #4
    Thanks @Lastic ! These are all great. To get the remaining battery capacity, I was doing a long winded ‘system_profiler SPPowerDataType | grep -i remaining’

    Yes, feel free to share more CLI tips and tricks. I’m sure there are plenty of users who will find this thread a handy reference. Although modern Macs can do the same, >console is probably more useful when run on older hardware due to fewer resources.
     
  5. Lastic macrumors 6502a

    Joined:
    Mar 19, 2016
    Location:
    North of the HellHole
    #5
    A few more interesting things :

    To lock your screen :D in screen Ctrl-A Ctrl-X as found here : https://askubuntu.com/a/186911

    When starting a Powerbook with an attached external Display , when you switch to >console your external Display will be used thus giving you more workspace .

    In case of my G5 hooked up to a 30" Cinema Display a lot of workspace .

    I succeeded in compiling the brightness scripts from my previous post but it doesn't work when in CLI only mode.

    Another hassle is LittleSnitch, when running in CLI only mode, it will block your outgoing connections and since you can't see the GUI prompt you cannot allow the connection temporarily .

    Somebody had made a script snitchCtl for this but it can't be found online anymore (not even WaybackMachine) , just FYI here's the info : http://hints.macworld.com/article.php?story=2005092816511024

    Only way to fix this is stopping LittleSnitch by doing (not secure)
    sudo launchctl unload /Library/LaunchDaemons/at.obdev.littlesnitchd.plist

    Another nice Ruby gem to show CLI only based tutorials or installs , showtime.io as explained here

    https://www.tecmint.com/showterm-io-a-terminalshell-recording-upload-and-share-tool-for-linux/

    Here is a CLI screen capture of CLI only PB G4 12" running screen and starting an text-only Debian 8 VM using Qemu.

    http://showterm.io/73e255e20a5c9186a790f#6500

    And last but not least , how do you check your RAM usage in CLI only , on Linux you would use free but on BSD this only
    exists as vm_stat which shows free memory in Pages not bytes.

    Hence this link to a handy Python script which will gather the info like "free" does :

    https://apple.stackexchange.com/que...-version-of-the-free-command-in-linux-systems

    I didn't find how to Split Screen in screen , @AphoticD any ideas ?

    I know how to do it with tmux but the Macports tmux has glitches , it doesn't show borders like the OpenBSD one nor colors (might be something with the term type)

    Well, I'm going back to my original quest of this Sunday , ansible + vagrant + qemu
     
  6. AphoticD thread starter macrumors 68000

    AphoticD

    Joined:
    Feb 17, 2017
    Location:
    Australia
    #6
    This is great! It seems the networksetup and airport tools aren't available on Tiger though.

    For split view in screen:

    Ctrl-a, S to create a new split
    Ctrl-a, Tab to focus on the new split view
    Ctrl-a, c to create a new shell in the new split view

    To close a split, exit from the shell, then Ctrl-a, Q you can then Ctrl-a, Tab to return to the last view which wasn't closed

    It looks like some versions of screen also have a vertical split view (Ctrl-a, |), but I couldn't get this to work in OS X.

    For help within screen, Ctrl-a, ?

    For a quick hack of a 'free'-like tool
    $ alias meminfo="top -n 0 -l 1 | grep -i mem"

    $ meminfo
    Code:
    MemRegions: num =  9854, resident =  428M + 21.5M private,  118M shared
    PhysMem:   522M wired,  251M active,  637M inactive, 1.38G used, 14.6G free
    
     
  7. Lastic macrumors 6502a

    Joined:
    Mar 19, 2016
    Location:
    North of the HellHole
    #7
    I found that networksetup is buried under OS X Tiger

    /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup-panther
    as found here : https://yourmacguy.wordpress.com/2008/08/07/networksetup-command/

    but it doesn't work for me in Tiger.

    Screen does split indeed in Tiger and Leopard , thanks for that very usefull hint.
     

Share This Page

6 February 24, 2018