Things You can do with Windows 10 Bash Shell | Basic Linux Commands

Things You can do with Windows 10 Bash Shell

Install Linux Software

Command :- apt-get install [package name]

The easiest way to install Linux software inside Bash is with the apt-get command. This command downloads and installs software from Ubuntu’s software repositories.

Change Your UNIX User Account

Command :- lxrun /setdefaultuser root

When you first set up Bash, you’ll be prompted to create a UNIX user account and set a password. You’ll be automatically signed in with this account each time you open the Bash window. If you want to change your UNIX user account–or use the root account as your default account in the shell–you can use lxrun command for this.

Uninstall and Reinstall the Ubuntu Environment

Command :- lxrun /uninstall /full

After you’ve installed some programs or changed some settings, you might want to reinstall the Ubuntu environment and get a fresh Linux slate.

Basic Linux Commands

pwd : prints working directory (prints to screen, ie displays the full path, or your location on the filesystem)
ls : lists contents of current directory
ls –l : lists contents of current directory with extra details
ls /home/user/*.txt : lists all files in /home/user ending in .txt
cd : change directory to your home directory
cd ~ : change directory to your home directory
cd /scratch/user : change directory to user on scratch
cd  : change directory to the last directory you were in before changing to wherever you are now
mkdir mydir : makes a directory called mydir
rmdir mydir : removes directory called mydir. mydir must be empty
touch myfile : creates a file called myfile. updates the timestamp on the file if it already exists, without modifying its contents
cp myfile myfile2 : copies myfile to myfile2. if myfile2 exists, this will overwrite it!
rm myfile : removes file called myfile
rm –f myfile : removes myfile without asking you for confirmation. useful if using wildcards to remove files
cp –r dir newdir : copies the whole directory dir to newdir. –r must be specified to copy directory contents recursively
rm –rf mydir : this will delete directory mydir along with all its content without asking you for confirmation!
nano : opens a text editor. see ribbon at bottom for help. ^x means CTRL-x. this will exit nano
nano new.txt : opens nano editing a file called new.txt
cat new.txt : displays the contents of new.txt
more new.txt : displays the contents of new.txt screen by screen. spacebar to pagedown, q to quit
head new.txt : displays first 10 lines of new.txt
tail new.txt : displays last 10 lines of new.txt
tail –f new.txt : displays the contents of a file as it grows, starting with the last 10 lines. ctrl-c to quit.
mv dir subdir : moves the directory called dir to the directory called subdir
mv dir newdirname : renames directory dir to newdirname
top : displays all the processes running on the machine, and shows available resources
ssh servername : goes to a different server.
grep pattern files : searches for the pattern in files, and displays lines in those files matching the pattern
date : shows the current date and time
anycommand > myfile : redirects the output of anycommand writing it to a file called myfile
anycommand >> myfile : appends the output of anycommand to a file called myfile
command1 | command2 : “pipes” the output of command1 to command2. the pipe is usually shift-backslash key
date | grep Tue : displays any line in the output of the date command that matches the pattern Tue. (is it Tuesday?)
man anycommand : gives you help on anycommand
cal : Shows calendar