Linux, Machine Learning, PowerShell, Windows

Machine Learning on Windows 10 – Part 2: Linux Command Line

In the last post we setup the Windows 10 WSL 2 subsystem, and deployed the latest version of Ubuntu.

In this post we will go over some common commands and features.

I will periodically update this post as I find new and interesting Linux\Windows commands.

  • Launching Linux\Ubuntu Bash shell (Linux command line)
    • Start Menu -> Ubuntu icon – This will bring up bash command line at the users home folder
    • Launch Windows Command Line or PowerShell – Navigate to any directory. Type wsl and hit enter -> This will switch to the Ubuntu bash command line. WSL will mount the windows file system and cd into the same directory. For example, if the Windows Command prompt was at c:\Users\ekiss\Downloads then the ubuntu command line will be at /mnt/c/Users/ekiss/Downloads
  • Microsoft has provided an updated console application called Windows Terminal. It can be downloaded from git (https://github.com/Microsoft/Terminal) or the Microsoft Store.
  • You can call Windows binaries from the Linux command line and Linux binaries from the Windows command prompt. To run Linux binaries from the Windows Command Line, or PowerShell, enter wsl before the command. e.g. wsl ls

Common terminal commands

Below is a list that I compiled. Additional commands and descriptions can be found online: https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/File_System_Utilities

CommandDescription
man sudo_rooHow to run administrative commands
apt list –upgradableGet a list of packages that are available to update
sudo apt-get updateTo update the deployed packages
pwdCheck which directory you’re in by entering (print working directory)
ls
ls – a
see what files are in the directory of your current path.
-a shows hidden files and folders
historyview list of recently used commands
cdchange directory
mkdir make a new directory
touchcreate a new text file. e.g.: touch readme.txt
vimtext editor. Exit by selecting Ctrl+C and then :q, or :wq if you want to save and quit
nanosimple text editor
catdisplay file contents. e.g.: cat readme.txt
manSee the manual pages for a command (for example, man tar) or try typing a command plus --help to see how the command can be used (for example, nano --help).
sudo locateThe locate is a command line utility for finding files by name in Linux. Locate package is provided by the GNU findutils or mlocate packages. If the locate command is not found, run “sudo apt install mlocate“. After the package is installed, run “sudo updatedb“. Once the database is updated you can use the locate command.
eg.: “sudo locate bash_completion.sh”
python3 -m http.serverStart a python web server. Navigate to a folder with the html file and type the command. Open a browser and enter: http://localhost:8000/[webpage].html

Resources:

https://docs.microsoft.com/en-us/learn/modules/get-started-with-windows-subsystem-for-linux/3-integration-between-linux-and-windows

https://www.tecmint.com/install-locate-command-to-find-files-in-centos/

https://docs.microsoft.com/en-us/windows/wsl/interop