Linux SHELL Guide
Shows all hidden files and folders along with normal ones.
ls -alist lot of information about non-hidden files and directories
ls -llist above info for hidden files and directories too
ls -la OR ls -l -ato switch to a dir same as cd but it just saves the path from which you came
pushd <path>to switch back to dir from which you came with pushd.
popdtells details of file
file <name of file>search a directory or a file in data base
locate <name of file or directory>or
mlocate <name of file or directory>NOTE: run before locate/mlocate to update database
sudo updatedbsee calander
calsee if command is installed or not, returns path of the command
which <command>brief one-line discription of what a command can do
whatis <command>shows the commands related to or contain given keyword
apropos <keyword>equivalent to apropos but show information in readable format
man <keyword>copy a files and directories
cp -r<path of the file to be copied> <name of the copied file>move files and directories
mv <path of file> <path to be moved>delete/remove files
rm <file>delete/remove directories
rm -r <directorie>create a text file.
touch <file_name>
echo 'write text here' > textfile.txt
printf 'write \\ntext \\nhere' > textfile.txtNOTE: use printf for format the text
show the content of a text file on terminal
cat <file>write into the text file
cat >> <file_name>copy file1 to file2
cat <file1> >> <file2>“>” operator will overwrite the existing data
“>>” operator will append data
bash text editor for editing files in CLI format. there are others too
nano <file1>
ls -la ~ >> textfile.txtswitch to root user or root account, to exit type exit
sudo -sswitch to another user account, to exit type exit
su - <username>move to root user account
su
su -see how many accounts are logged in
usersexecutable permission to file for everyone
chmod +x <file_name>get the PID of programme and all its instances
pidof bravesee the running process
topkill process by their name
pkill brave
killall bravekill process by their PID
kill <PID of the process>get the snapshot of top (Best)
ps aux | grep <name of programme or running file or path or aything relatable to it>find the exact package
apt search --names--only ___Install .deb files, then fix missing dependencies
sudo dpkg -i /path/to/.deb/file
sudo apt-get install -fsee package details and dependencies
apt-cache showpkg package-name
apt-cache depends package-namesee package info
dpkg-deb -I package.debcreate and edit cronjobs (scheduled server tasks)
crontab -esee cronjobs on terminal
crontab -lcreate a SCREEN session with name
screen -S <name_of_session>see detached and running screen session
screen -lsreattach to detached screen session
screen -r <pid_of_screen_session>see cronjobs-logs with
journalctl -t CRONDinstall/extract tar files
tar xvf <file_name>Find Public IPv4 address
dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.comFix bluetooth in ubuntu>18.04
sudo modprobe -r btusb && sudo modprobe btusbInstll/Add PPA repository
sudo add-apt-repository ppa:dr-akulavich/lighttable # adds repository link to /etc/apt/source.list
sudo apt-get update
sudo apt-get install lighttable-installer # installing the softwareRemove PPA repository and link
listppa.shUse the above script to see the list of installed PPAs
now remove the ppa
sudo add-apt-repository --remove ppa:bluetooth/bluezCheck mounted/connected disks to the system
lsblkCommand for burning USB {notice the of and if carefully}
sudo dd bs=4M if=Downloads/endeavouros-2021.08.27-x86_64.iso of=/dev/sdb conv=fdatasync status=progressSet-up ssh key for connecting to git
eval "$(ssh-agent -s)"
chmod 400 <private_key_file>
ssh-add ~/.ssh/<private_key_file> > /dev/null 2>&1https://stackoverflow.com/questions/10508843/what-is-dev-null-21
Pacman, AUR
List dependency of a package
pacman -Si
or
pacman -Si package_name | grep 'Depends On'
or
pactree -s package_name
or
pactree -sr package_name #see reverse dependency
or
pactree package_name -lu #in format for reinstalling dependencySee locally installed packages~ AUR(s) or installed with AUR helpers.
pacman -Qm or pacman -QmqTo list all the Fonts installed in your system
fc-listHow to add users in arch Linux
Create the user with adduser or useradd, whichever is present in your system, then set a password for NAME.
useradd NAME
passwd NAMEGive Sudo Privileges to NAME
To give sudo rights to a user you can add him to group wheel. Wheel is the group for users who get every system administrator privilege.
gpasswd -a NAME wheelUsers of the wheel group also need root privileges in /etc/sudoers, otherwise even if you add users to wheel group they will not be able to use sudo. Always edit /etc/sudoers with sudo visudo to avoid errors, and add this line for wheel group users:
%wheel ALL=(ALL) ALLOr you can give a single user root privileges by adding this line to /etc/sudoers. If you choose to do this then you don’t need to add NAME to wheel group.
USER_NAME ALL=(ALL) ALLBut the first approach is recommended.