hostname #returns name of current boxhostname -b <NEW_NAME> #Sets name to box. also done by editing /etc/hosts and /etc/hostname.#indicates current os architecture is 32/64 bit
echo $(getconf LONG_BIT) #OR,uname -muname -a #Detailed info about box. df -h #Displays all mounted partitions and their size/usage/availability/mount-point...du -sh <DIRECTORY/FILE> #displays size(disk usage) sumed-up and in human readable format.free -m #shows RAM Usage and availability in MBs.cat /proc/meminfo #Alternate : lsmem,Displays all info about RAM.cat /proc/cpuinfo #Alternate : lscpu,Displays all info about CPU.cat /proc/modules #Alternate : lsmod,Displays all info about loaded kernel modules.cat /etc/shells #Displays all available shells (ex- sh, bash... ).bash -version #Displays bash version.blkid #Alternate : lsblk, Displays all block devices(hardrive-partitions, mounted-cd/dvd).top # Then hit following as required.c # shows complete path of each path.F # selecting sort field.1 # show all cpu cores.top -p <PID> #displays info about specified processid only.netstat -tulnp #Displays all open TCP/UDP ports. Use grep to find if port is in use or not.sync; echo 3 > /proc/sys/vm/drop_caches #clear cache.#File Permissons : In linux, access to files are granted based on ownership. whether a user is owner, or in same group as owner or other. Each file holds access-levels for all three type of users.
Access levels- (Read[4], Write[2] & Execute[1]) 4+2+1 = 7
Ownership - (Owner, Group user & Others)
chmod 777 <FILE_NAME> #grants read write & execute permission to everyone.*1st character in result of 'ls' indicates type of file.(- is regular file, d is directory, l is link file)
*2-10 characters are permissions in set of 3 for 3 users.(r-read, w-write, x-execute) for File-Owner , User-in-owner-group , other-users .
ls #lists name of current path content(s).ls -l #lists content(s) of current path with details.ll #lists content(s) of current path, same as ls -l.ls -ltr #lists content(s) sorted on modified time in reverse order.ls -h #lists content(s) in human readable format(e.g-size in kb).ls -a #list All(including hidden) files/folders in current path.cut -d: -f1 /etc/passwd #lists all available users.less /etc/group #lists all available groups.useradd <USER> #Creates new user. see useradd -h for group assignment & otherspasswd [<USER>] #resets self/specified user password.usermod -aG <GROUP> <USER> #Adds user to group.visudo #allows to configure sudo rights for usersulimit -n 65536 #sets max number of open files to 65536.ulimit -u 2048 #sets number of threads.sysctl -w vm.max_map_count=262144 # virtual memory limits. /etc/sysctl.conf#1. Create file with required swap size.dd if=/dev/zero of=/application/swapfile1 bs=1024 count=10485760#2. convert file to swap partition mkswap /application/swapfile1#3. change ownership of swapfilechown root:root /application/swapfile1chmod 0600 /application/swapfile1#4. change swap target.swapon /application/swapfile1#5. setup fstab to mount automatically this newly created swap partition vi /etc/fstab #open file for editing, and append following./application/swapfile1 swap swap defaults 0 0Enter>~>. #releases stuck terminals due to broken connections.Ctrl + F #Search in terminal logs..Shift + PgUP/Dn #scrolls terminal output (even in virtual box with console only installations)# User privilege specificationroot ALL=(ALL:ALL) ALL