Showing posts with label system. Show all posts
Showing posts with label system. Show all posts

Monday, March 20, 2023

Reset Windows passwords with chntpw using a Linux Live USB

Have you ever forgotten your Windows login password and been locked out of your own computer?
There is a way to reset your Windows password using a Linux Live USB drive and a tool called chntpw. Here, we will show how.


Step 1: Create a Linux Live USB drive

First, you'll need to create a Linux Live USB drive. You can use any Linux distribution that includes the chntpw package. We will be using Ubuntu:

  • Download the Ubuntu ISO file from the official website.
  • Burn the ISO file to a USB drive using a tool like Rufus or Etcher.
  • Boot your computer from the USB drive.

Step 2: Install chntpw

Once you have booted into the Linux Live USB, you'll need to install the chntpw package. To install chntpw, open a terminal and run the following command:

sudo apt install chntpw

Step 3: Mount the Windows partition

Next, you'll need to mount the Windows partition that contains the password database. In the terminal, navigate to the directory where the Windows partition is mounted. This will typically be the Windows/System32/config/ directory.

cd ~/winmount/Windows/System32/config/

Step 4: List the Windows users

Now, list the Windows users stored in the password database by running the following command:

sudo chntpw -l SAM

This will display a list of Windows users along with their corresponding User IDs (UIDs).

Step 5: Reset the Windows password

Finally, you can reset the password for a specific Windows user by running the interactive command:

sudo chntpw -i SAM

This will launch a menu where you can select the user whose password you want to reset and also unlock accounts. Follow the prompts to reset the password. Then reboot into Windows.


Sources: https://doc.ubuntu-fr.org/tutoriel/chntpwhttps://ostechnix.com/reset-windows-password-with-linux-live-cd/

Friday, February 12, 2021

nettop: monitor the per-process bandwidth usage in OSX

This command will display the network usage of all the running processes


   nettop -P -k state,interface -d -s 3


Flags explained:

-s refreshes every 3 seconds

-P collapses the rows of each parent process

-k state,interface removes less informative columns that stand between you and the bytes in/out columns

-d activates the delta option (same as pressing the d button)

Use the h button or run man nettop for some more options.


source: https://apple.stackexchange.com/questions/16690/how-can-i-see-what-bandwidth-each-app-or-process-is-using

Thursday, July 14, 2016

Error associating all .ply files to MeshLab in OSX El Capitan


When trying to associate MeshLab application to all the .ply files with the Always open with or Change All...  buttons I get the following error
An unexpected error occurred (error code -10813).
The operation could not be completed.

The problem is that MeshLab is missing the key CFBundleIdentifier in its Info.plist.
To solve the problem edit its plist file
> open /Applications/meshlab.app/Contents/Info.plist 
and add the key CFBundleIdentifier with value com.vcg.MeshLab.

Then touch the application tell OS X about the change
> touch /Applications/meshlab.app
And retry associating the file type.

Sunday, January 12, 2014

SMC reset. Random system freezes, and unresponsive keyboard & touchpad after plugging USB device

Lately I had some problems with my macbook air. Random system freezes, and unresponsive keyboard & touchpad after re-opening the lid.

I first tried a memory diagnostic (by booting pressing 'D') to discard a memory fault, but the RAM was OK. After surfing the web I found that I may have been needing to reset the SMC (System Management Controller). So I did, it but in the end the system continued to randomly freeze after plugging some USB devices.

Reset Macbook Air's SMC
  1. Shut down the computer 
  2. Plug in the power adapter if its not already connected.
  3. On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
  4. Release all the keys and the power button at the same time.
  5. Reboot as usual.
The procedure for other Mac's is slightly different, so it's better to look them up here or here.

Solution to unresponsive keyboard & touchpad after plugging USB device

In the end the culprit of this behavior was the android file transfer tool. What solved my issue was to disable the autostart of this application.



    Saturday, August 25, 2012

    Change text inside multiple files (command line)

    I always forget these commands, and they are so useful.
    The sed command to replace some text in a set of files:
         sed -e 's/old text/new text/g'  -i .trash  *.c 

    The regular expression 's/some text/new text/g' is applied to each line of each file *.c.
    And the -i flag saves a backup of each file.

    The regular expression language is powerful, for instance allows to remember parts of the pattern in the substitution. An example: the following command puts quotation marks around everything that follows the first = sign in each line of script.sh.
      sed -e 's/=\(.*\)/="\1"/' script.sh

    The pattern enclosed between \(   and   \) is stored in \1, and then used in the replaced text.

    Source: http://www.labnol.org/internet/design/wordpress-unix-replace-text-multiple-files/1128/

    otool: shows the shared libraries of a file (like ldd)

    In OSX, the command to show the shared libraries that a binary uses is:
       /usr/bin/otool -L  binary_file

    In Linux and Solaris the equivalent command is ldd, and I am used to it,
    so I have this alias in my ~/.bash_profile  file:
       alias ldd="/usr/bin/otool -L "

    Thursday, August 16, 2012

    Homebrew package manager for OSX + Tips

    Forget Fink and MacPorts, Homebrew is the miracle package manager you are looking for.

    Homebrew installs packages to their own directory and then symlinks their files into /usr/local.
    Then there is no need to tweak the system's and compiler's search paths to reach the packages. Also the installation is extremely simple, and the syntax familiar:
      brew [search, install, remove] packagename

    The big critic I read about was the lack of packages. Never noticed, probably because the number of packages have exploded during the last year. The packages are built locally, so compiling large applications may take considerable time.

    Tips:
    • Compile for multiple architectures. If, for some reason, you need to compile a program/library with multiple architecture support, like on a 64bits system but with 32bits legacy applications. Then, while installing use the --universal flag:
           brew install --universal -v libtiff
      it will compile a "fat" library with multiple architectures (env UNIVERSAL_ARCH="i386 x86_64" to specify which architectures).
    • Python. This setting is very important, but may depend on the version of OSX.
      When I installed Homebrew it did not compile its own python, instead it used the python that came with the system. Then all python packages installed with Homebrew are stored in: /usr/local/lib/python2.6/site-packages,  which is not in the search path for  python. It must be specified with the environment variable PYTHONPATH, by adding this line to ~/.bash_profile :
        # CONTRIBUTED PYTHON LIBRARIES
       
        #------------------------------------------
       
        export PYTHONPATH=/usr/local/lib/python2.6/site-packages:$PYTHONPATH
       
        #------------------------------------------


      More on Python and Homebrew.
    • Big projects like GIMP, Inkscape, Firefox,  and many others...  Are not available as packages, they are already distributed as standalone OSX applications.

    Wednesday, August 15, 2012

    Two-finger scrolling in Windows laptops (also Linux)

    Two-finger scrolling and two-finger tapping (right click) are the two multi-finger gestures that I use the most in Mac. I'm so habituated to them that when I use a Windows laptop becomes a frustrating experience: always reaching for the right button or the scroll area of the pad.

    Turns out that Synaptics TouchPads allow multi-finger gestures, and it is just a matter of drivers to enable them (just to be clear, almost all TouchPads out there are Synaptics).
    Even better, without manipulating the driver. Two-Finger-Scroll is a small application that allows to enable two and three finger gestures on the Synaptics TouchPads, and it works just fine.

    Source: http://www.howtogeek.com/howto/35065/how-to-enable-macbook-style-two-finger-scrolling-on-windows-laptops/

    Update: multi-finger gestures also available for Linux!!  In Ubuntu/Debian just install the gpointing-device-settings package, or anything that says Synaptics.

    Friday, August 10, 2012

    Record audio from the system output

    soundrec.exeBy default in OSX it is not possible to record audio from the system output. This occurs if you try to record sound from an application, like a web browser.
    Moreover, besides GarageBand there is no integrated lightweight sound recorder in OSX (like the old and reliable soundrec.exe).



    The solution to the first problem is provided by an Audio Routing device/application.
    Soundflower is popular open source extension that allows applications to pass audio to other applications. This article explains how to use it.
    Jack is another free option but apparently has more features and is more complicated to use. Other popular non-free options are WireTap and Rogue Amoeba.

    As for recording under OSX, Audacity is a free and "lightweight" (80Mb) application that works.

    Sources:
    http://gerrybeauregard.wordpress.com/2011/08/31/soundflower-great-tool-for-recording-the-macs-audio-output/
    http://www.macworld.com/article/1159440/soundflower_capture.html

    Wednesday, August 8, 2012

    Find broken symbolic links

    To list the symbolic links along with where they point to:

         find -L /PATH/TO/SEARCH -type l -exec ls -l {} \;  

    Omitting  -exec ls -l {} \;  will just list the link name.

    Other references: http://how-to.wikia.com/wiki/How_to_find_broken_symbolic_links

    Sunday, May 13, 2012

    Tips and secrets for speeding up OSX

    Just a couple of links for the moment. Some of the tips are outdated (older than OSX 10.6.8).
    http://www.mahalo.com/how-to-speed-up-osx/
    http://secrets.blacktree.com/?show=all

    Sunday, April 29, 2012

    MATLAB: "Trace/breakpoint trap" after system call

    The MATLAB's system call permits to run a program in a shell. But some programs have dynamic dependencies that conflict with MATLAB's environment. For instance:

    [status, result] = system(['/usr/local/bin/convert']); 

    will throw something like:


    dyld: Library not loaded: /opt/local/lib/libtiff.3.dylib
      Referenced from: /opt/local/bin/convert
      Reason: Incompatible library version: convert requires version 13.0.0 or later, but libtiff.3.dylib provides version 11.0.0

    /usr/local/bin/convert: Trace/breakpoint trap 

    A solution consists in resetting the variable DYLD_LIBRARY_PATH (for OSX or LD_LIBRARY_PATH in Linux)  before running the program. This call should do the trick:

    [status, result] = system(['export DYLD_LIBRARY_PATH=""; ' '/opt/local/bin/convert']); 

    Source: http://www.alecjacobson.com/weblog/?p=1453

    Wednesday, November 23, 2011

    SSH Dynamic Port Forwarding (SOCKS server)

    Dynamic port forwarding turns your SSH client into a SOCKS proxy server. SOCKS is widely-implemented protocol for connecting programs to Internet through a proxy server. Each program that uses the proxy server needs to be configured specifically.
    Say you wanted Firefox to connect to every web page through your SSH server in a remote host.

    First you would setup the dynamic port forwarding with the default SOCKS port:

    ssh -C -D *:1080 your.remote.host

    The -D option specifies dynamic port forwarding. 1080 is the standard SOCKS port, and *: indicates to listen in all the interfaces (not only 127.0.0.1) . -C enables compression, which speeds the tunnel up.

    Next you would tell Firefox to use your proxy:
    • go to Edit -> Preferences -> Advanced -> Network -> Connection -> Settings...
    • check "Manual proxy configuration"
    • make sure "Use this proxy server for all protocols" is cleared
    • clear "HTTP Proxy", "SSL Proxy", "FTP Proxy", and "Gopher Proxy" fields
    • enter "127.0.0.1" for "SOCKS Host"
    • enter "1080" for Port.
    You can also set Firefox to use the DNS through that proxy, so even your DNS lookups are secure:
    Type in about:config in the Firefox address bar
    Find the key called "network.proxy.socks_remote_dns" and set it to true

    To make other programs use your SSH proxy server, you will need to configure each program in a similar way.
    The SOCKS proxy will stop working when you close your SSH session.

    Source: https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding#Dynamic_Port_Forwarding

    Saturday, October 15, 2011

    Optimizing Mac OS X for SSD drives (update: Safe Sleep tuning)

    This article: http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/ recommends to reduce the writes on SSD drives to increase their lifespan. The proposed actions go in the direction of reducing un-necessary writes and disable legacy options linked to spinning hard drives.
    I'm using: 1(with modified deepsleepdelay), 2, 3 and 4.

    1. Alter the Sleeping mode 
    By default, when closing the lid on a MacBook, the content of the ram (random-access memory) is saved to disk for safety. The ram is still powered on however, and is used when starting up again. The content saved on disk is only used in case of a power loss.

    • This behavior can be changed so that ram content is not saved to disk.
    $ sudo pmset -a hibernatemode 0 
    This means that the laptop will never enter DeepSleep (or hibernation, that is the ram is always powered and in the event of a power loss the state is lost), and in this case the sleepimage /var/vm/sleepimage can also be removed.

    • The default setting (SafeSleep) can be restored with: 
    $ sudo pmset -a hibernatemode 3

    • There is an intermediate behavior of SafeSleep, which delays the writing of the sleepimage for some time. This is controlled by the deepsleepdelay parameter (or standbydelay), by default set to 4200 seconds, meaning that the seleepimage is written 70 minutes after closing the lid. This may be too short.
    To make it wait 12hs before writing the image to disk run:
    $ sudo pmset -a deepsleepdelay 43200
    or, on systems with OS X ≥ 10.6.8,
    $ sudo pmset -a standbydelay 43200
    during this time only the ram is powered and the wakeup is immediate. After 12 hours of sleep, the memory content is dumped to the sleepimage and the memory is powered off.
    I'm currently trying this setting.

    In conclusion, SafeSleep (hibernatemode 3) combined with deepsleepdelay <seconds> covers a wide range of sleepping/hibernating behaviors. It can even emulate the hibernatemode 0 (never save a sleepimage) just by setting a deepsleepdelay big enough.

    2. Disable Hard drive sleep 
    Putting SSD hard drives to sleep has no benefit. 
    This can be disabled under System Preferences -> Energy Saver

    3. Disable Sudden motion sensor 
    $ sudo pmset -a sms 0

    4. Enable noatime for SSD filesystems 
    Every time a file is accessed its access time is modified to reflect it. This can be disabled to save additional writes. To do this for the local filesystem create the file /Library/LaunchDaemons/com.noatime.root.plist with the following content.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
        <dict>
            <key>Label</key>
            <string>com.noatime.root</string>
            <key>ProgramArguments</key>
            <array>
                <string>mount</string>
                <string>-uwo</string>
                <string>noatime</string>
                <string>/</string>
            </array>
            <key>RunAtLoad</key>
            <true/>
        </dict>
    </plist>
    This will execute mount -uwo noatime / upon system startup,

    5. Disable Spotlight 
    $ sudo mdutil -a -i off

    Sources and resources:
    http://larvecode.tumblr.com/post/9622045759/osx-on-ssd
    http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/
    http://www.macworld.com/article/53471/2006/10/sleepmode.html
    http://www.uponmyshoulder.com/blog/2011/deep-sleep-on-macbook-air-late-2010/
    http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/pmset.1.html

    Tuesday, September 27, 2011

    OSX Hotkeys for screen lock, invert colors and dictionary

    The keyboard shortcut: Control+Shift+Eject
    blanks immediately the screen and locks if set to do so (with “Require password after sleep or screen saver begins” enabled).


    The keyboard shortcut: Control+Alt+Cmd+8
    inverts the screen colors. This is ideal for presentations when the visibility due to the lighting conditions is poor.


    The keyboard shortcut: Control+Cmd+D
    pops-up immediately the dictionary with the description of the word under the cursor.



    Source http://osxdaily.com/2011/01/17/lock-screen-mac/http://www.silvermac.com/cool-things-to-do-on-mac/

    Monday, June 13, 2011

    Create user account from the OS X command line

    Here is a procedure for adding a new user in OS X from the command line.
    The problem is that there is no useradd or adduser in OS X, so the user must
    be added to the Directory Service by hand.

    1. First make sure to find an unused uid (unique ID) for the user,
      dscl . -list /Users UniqueID
      will list all the existing users, an unused number above 500 is good.

      In general to list a property from the directory use:
      dscl . -list {users|groups} {u|g}id
      or to see the id's of an existing user use:
      id auser

    2. The Add the directory entry:
      dscl . -create /Users/luser
      dscl . -create /Users/luser UserShell /bin/bash
      dscl . -create /Users/luser RealName "Lucius Q. User"
      dscl . -create /Users/luser UniqueID "503"
      dscl . -create /Users/luser PrimaryGroupID 20
      dscl . -create /Users/luser NFSHomeDirectory /Users/luser


      The PrimaryGroupID=20 is usually staff. 80 is admin, it can be added with:
      dscl . -append /Groups/admin GroupMembership luser

    3. Set the password:
      dscl . -passwd /Users/luser password
      or
      passwd luser

    4. Finally, create the home directory with the appropriate permissions:
      mkdir /Users/luser
      chown luser:staff luser

      or even better, create and populate the directory with
      createhomedir -c -u luser




    Further reading: http://serverfault.com/questions/20702/how-do-i-create-user-accounts-from-the-terminal-in-mac-os-x-10-5

    Sunday, June 12, 2011

    Connecting to WiFi Network with hidden SSID

    In order to connect to a network with hidden SSID (i.e. that does not broadcast it) in OS X 10.5 (in 10.6.8 this issue has been solved) the network must be configured each time we want to connect, even if the network appears in the advanced configuration preferences.

    To the moment the best solution I've found is to forces the connection with the following shell command:
    sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --associate=yourHiddenSSID --password=yourkey

    Source: http://superuser.com/questions/43836/automatically-connecting-to-hidden-ssid-wifi-network

    Monday, April 25, 2011

    Extract content from a pkg or mpkg "file"

    Ever wondered what's inside a .pgk or .mpkg file?
    In general they are directories so it can be accessed from the shell, or right-clicking it and choosing "Show Package Contents". The application data is packed in the file named: Archive.pax.gz.
    To uncompress it:
       gunzip Archive.pax.gz
       pax -rvf Archive.pax

    and voilĂ , behold all the package content unrolled before you.

    I the right-clicking does not work then the .pkg is not a directory but a file. In this case there is a handy application named unpkg, that will just do the trick.


    Sources:
    http://en.wikipedia.org/wiki/Pax_(Unix)
    http://www.linuxquestions.org/questions/linux-general-1/cant-extract-macosx10-4-universal-pkg-678167/
    http://www.macupdate.com/app/mac/16357/unpkg

    Wednesday, December 8, 2010

    Import electronic certificate into OSX Keychain for Safari & Chrome

    By mistake I've used Safari for obtaining a public key certificate from a website that was designed for Firefox or Internet Explorer. At the end of the procedure I've downloaded a file (descargarCert) but the certificate was not installed in the Keychain. I assume that Firefox should recognize the certificate's format and install it automatically, but Safari did not.
    After some googling I've discovered that the X.509 certificate formatted as PEM file, and Keychain needed DER.
    • First split the long lines of the original file, with less than 75 chars per line;
    • Then run:
         openssl pkcs7 -inform PEM -in descargarCert -outform DER -out certificate.der -print_certs
    • Lastly import the certificate into the Keychain by opening the output file: certificate.der
    Sources:
    http://bitacorasigloxxi.wordpress.com/2008/04/28/certificado-digital-fnmt-en-mac-os-x/
    http://www.applesfera.com/mac-os/applesfera-responde-certificado-digital-de-la-fnmt-en-mac-os-x