Linux ===== Commands -------- List all files in current directory **ls** List all files in current directory including hidden items **ls -a** List all files in current directory with details **ls -l** List all txt files in current directory **ls \*.txt** Change the current directory cd directoryname Go up 1 level cd .. Copy a file or folder **cp oldfile.txt newfile.txt** Note that to copy the contents of a folder you need to specify the -R flag Move/Rename a file or folder **mv oldfile.txt newfile.txt** Delete a file without confirmation prompt **rm filename.txt** Delete a file with confirmation prompt **rm -i filename.txt** Delete a directory **rmdir directorytodelete** Note that this command will only delete the directory itself and not the contents of the directory Delete the contents of a directory with confirmation prompt rm -ir \[foldername\] mkdir List all users **getent passwd** https://linuxize.com/post/how-to-list-users-in-linux/ Mounting Volume Syntax: mount -t type device dir sudo mount -o remount,rw /media/linux/OLD\_PC� /media/linux/OLD\_PC List drives currently connected to the system sudo fdisk -l or sudo blkid or lsblk or sudo parted -l List drives by UUID ls -l /dev/disk/by-uuid List mounted drives cat /proc/mounts or mount or df -aTh or findmnt https://www.rapidtables.com/code/linux/cp.html Repair Damaged File System -------------------------- 1. Boot the machine using external live media 2. Use the follow command to list filesystem partitions **sudo fdisk -l** 1. Use the following command to unmount the partition that needs to be repaired (it probably will already be unmounted but it is good to do this step to be certain because running this command on a mounted partition could cause other issues) **sudo umount /dev/sda1** 1. Use the following command to repair the file system **sudo fsck -p /dev/sda1** https://www.linuxshelltips.com/repair-ubuntu-filesystem/ https://www.tecmint.com/fsck-repair-file-system-errors-in-linux/ Reset Ubuntu Admin User Password -------------------------------- Option 1: 1. Turn on the machine and hold the Shift key to load the GRUB Bootloader menu (if it doesn�t appear automatically) 2. Choose the recovery mode option 3. Choose the �Root � Drop to root shell prompt� option 4. Remount the root partition with write access **mount -rw -o remount /** 1. List all user accounts **ls /home** 1. Reset the password using the following command, substituting �username� with the username of the account to reset the password of (if you get �Authentication token manipulation error�, it means that the file system is mounted with read only access) **passwd username** 1. Exit the terminal **exit** Option 2: 1. Turn on the machine and hold the Shift key to load the GRUB Bootloader menu (if it doesn�t appear automatically) 2. Press �E� to edit the command 3. Find the line starting with �**linux**� and change the �**ro**� in that line to �**rw**� and append �**init=/bin/bash**� at the end 4. Press Ctrl + X to boot 5. List all user accounts **ls /home** 1. Reset the password using the following command, substituting �username� with the username of the account to reset the password of (if you get �Authentication token manipulation error�, it means that the file system is mounted with read only access) **passwd username** 1. Shut down the machine **sudo halt** https://www.hiroom2.com/2016/05/20/ubuntu-16-04-reset-forgotten-password/ https://www.hiroom2.com/2016/05/20/ubuntu-16-04-fix-mojibake-on-recovery-mode/ https://itsfoss.com/how-to-hack-ubuntu-password/ [https://www.tecmint.com/reset-forgotten-root-password-in-debian/](https://www.tecmint.com/reset-forgotten-root-password-in-debian/) [https://monovm.com/blog/how-to-change-linux-password/](https://monovm.com/blog/how-to-change-linux-password/) Change VT (Virtual Terminal) Most distributions support switching to a different VT with Alt+F1 , Alt+F2, etc A graphical environment (X-window) is just one of those VTs, often 6th or 7th. To switch from an X-Window session to another VT you need to press Alt+Ctrl+F1, e t.c. (unless this is forbidden through novtswitch option) Grub boot loader stuff Edit the file /etc/default/grub **sudo gedit /etc/default/grub** Open a terminal with Ctrl + Alt + T and type **sudo update-grub** to apply the changes you just made You can use an application called Grub Customizer sudo add-apt-repository ppa:danielrichter2007/grub-customizer sudo apt-get update sudo apt-get install grub-customizer