Home Ubuntu WSL 2
Post
Cancel

Ubuntu WSL 2

What is?

Install & Config

Running WSL

With Start Menu

  1. using start menu,
  2. find for Ubuntu

using Powsershell

  1. Open Powershell, (press WinCtl + x, type i )
  2. type wsl on terminal
  3. dan kamu will login to ubuntu in current location you type the command

Or you can select from terminal dropdown tab, to open new tab as ubuntu wsl, seperti pada gambar berikut

Desktop View

Usefull Command

Powershell

CommandDescriptions
wsl -vcek versi
wsl -lcek distro
wsl -l -vcek versi dan list distro
wsl –helpman page wsl
wsl –list –onlinelist distro online
wsl.exe –installinstall default distribution
wsl –set-default-version 2set to version 2 wsl version

Install other distro: wsl --install -d <Distribution Name>

Ganti Default User

CommandDescriptions
ubuntu config –default-user new_user_nameganti default user distro ubuntu

NOTE: Perintah diatas digunakan di powershell sebelum masuk ke mode wsl

CommandDescriptions
wslfetch 
pwd 
whoami 

NOTE: Perintah diatas digunakan setelah masuk ke mode wsl

Running ubuntu command with wsl

  • tanpa masuk dulu mode linux
  • tambahkan wsl sebelum kode perintah under linuxnya
    • Ex: Cek status ssh wsl service ssh status

WSL Packages & Services

CommandDescriptions
sudo nano /etc/apt/sources.list 
sudo apt update 
sudo apt full-upgrade 
sudo apt-get purge –auto-remove gedit..
code .vscode wsl remote, using code on windows system

by default systemctl was disable because system has not been booted with systemd as init system. gunakan perintah service to check services on wsl, misalkan service ssh status, kalo mau dari powershell wsl service ssh status

kalo ada error ssh gak bisa di start, update dan upgrade dulu, sudo apt update && sudo apt upgrade {: .prompt-info }

CommandDescriptions
service –status-alldisplay all services on ubuntu wsl
service ssh statuscek status sshd
sudo service ssh startstart sshd
sudo service ssh stopstop sshd
service ssh –full-restartrestard sshd

System Informations

CommandDescriptions
lscpudisplay information about the CPU architecture
lshwlist hardware
duSummarize disk usage of the set of FILEs, recursively for directories
dfreport file system disk space usage
fdiskmanipulate disk partition table
vmstatReport virtual memory statistics
uptimeuptime running pc
ip acheck ip address
ip addrcheck ip address
ip addr | grep eth0 

Manage Process

CommandDescriptions
echo $PATHdisplay path environment
psdisplays information about a selection of the active processes, eg: ps -e, pas -a
treelist contents of directories in a tree-like format
pidof -z sshdList zombie and I/O waiting processes. May cause pidof to hang.
pstreeDisplay a tree of processes
topdisplay Linux processes with dynamic real-time view of a running system
htopmostly like top interactive process viewer

Users & Groups

CommandDescriptions
cat /etc/passwd 
useraddcreate user only
usermodcreate user only
userdelcreate user only
addusercreate user also create /home/jack, eg: sudo adduser jack
usermodmod jack as group sudo sudo usermod -aG sudo jack
cat /etc/passwd 
groupaddgroupadd marketing accounting
groupmodgroupmod -n marketing old_group
groupdel 
gpasswdadminister /etc/group and /etc/gshadow
gpasswd -a jack marketingadd jack to group marketing

Permissions

CommandDescriptions
su jackswitch as jack in current session
su - jacklogin to jack environment new session
sudo cat /etc/sudoersuse sudo visudo to modify

Working with Files and Directories

CommandDescriptions
lslist dir
cdchange dir
|pipe
lesseg: ls /etc/ | less
moreeg: ls /etc/ | more

hash

CommandDescriptions
hash 
cksum 
find 
grep 
diff 
CommandDescriptions
ln file1 fileAhardlink file1 shortcutnya fileA
ln -s folder1 sym-folder1simbolic link

Compression

CommandDescriptions
tarcompress: tar -cvf tarball.tar file1 file2 file 3
 extract: tar -xf tarball.tar
gzipcompress: gzip marketing.tar
 extract: gzip -d marketing.tar.gz
zipzip -r [foldername]
 unzip [foldername]

Manage Log

CommandDescriptions
lastlog 
ls /var/log 
cat /var/log/apt/history.loggrep purge

SSH to AWS EC2

  • using key.pem method

    1
    
    sudo ssh -i /path/to/key.pem username@<remote_host_ip>
    

LAMPP

Linux Apache PHP MySql PHP PhpMyAdmin

Apache

PHP

MySql

PhpMyAdmin

Network

change hostname

hostname hostnamectl hostnamectl set-hostname sudo nano /etc/hosts

Install Packages untuk Belajar

Install NodeJS

  1. Install NVM (Node Version Manager)

    Or See this post: posts/nvm/

This post is licensed under CC BY 4.0 by the author.