Skip to content

Latest commit

 

History

History
248 lines (168 loc) · 4.97 KB

File metadata and controls

248 lines (168 loc) · 4.97 KB

Linux Basic Commands

  • Compatible and Tested with: 14.04+, 16.04+, 18.04+

FOLDER AND FILE PERMISSION SETUP

  • Change mode all with group write.
chmod -R g+w /path
  • Change mode folder permission to drwxr-xr-x, will assign read, write and execute permission to the owner, and just read and execute permission to everyone.
chmod -R 755 = for directories
  • Change mode file permission to -rw-r--r--, also means that files are readable and writeable by the owner of the file and readable by users in the group owner of that file and readable by everyone else.
chmod -R 644 = for files
  • Change owner of the directories/files.
chown -R www-data:www-data /path
chown {user:group} path/file.ext
  • For accurate or automatic set of permission.
find {./path} -type d -exec chmod 755 {} \; # For Directory
find {./path} -type f -exec chmod -Rf 644 {} \; # For Files

FOLDER AND FILE COMMANDS

  • File Rename. Its primary purpose is moving files and folders, but it can also rename them, since the act of renaming a file is interpreted by the filesystem as moving it from one name to another.
mv /path/source /path/destination
  • File Copy.
cp {-R} source/file path/file (-R is for recursive copy)
cp source/file /path/file (So far this is for the single copy tested)
  • Folder or File Remove. (This will delete permanently)
rm -rf path/file
  • Change directory view.
cd path/file
  • View file using VIM. (This will need apt-get install vim)
vim path/file
  • To view the Root trash bin.
/root/.local/share/Trash/trash_files
  • To compress a file using tar.
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
  • To decompress a file using tar.
tar -xzvf /path/to/source/archive.tar.gz -C /tmp
  • To check the directory or file size.
du -sh directory/
  • To check the free space in the disk
df -h .

NETWORK CONFIGURATION

  • To view the nmap NAT for host/ip. (This will need apt-get install nmap)
nmap {host/ip}
  • To show ip address of the current machine.
ip addr show
  • IP Tables. (This will need apt-get install iptables)
iptables -t nat -L
  • The Firewall for ubuntu, this may help for preventing unwanted access to the server, atleast a first layer of protection.
ufw enable
ufw disable
ufw allow {port}
ufw deny {port}
ufw reset
  • To show the bridges in ubuntu. (This will need apt-get install bridge-utils)
brctl show
  • Flush DNS in Ubuntu/Linux.
sudo /etc/init.d/dns-clean restart
  • Restart network in Ubuntu/Linux.
sudo /etc/init.d/networking force-reload
  • Route Table Management (This will show the current list of route(s) in the table).
route add -net x.x.x.x (The IPADDR of route that will be adding) netmask 255.x.x.x gw (The current gateway of the local machine) 192.x.x.x
route del -net x.x.x.x/24 (The destination IPADDR, the 24 will be depend on the size of the IPADDR by default 24 can be use)

UTILITIES

  • VGA or graphic card status.
lspci -vnnn | perl -lne 'print if /^\d+\:.+(\[\S+\:\S+\])/' | grep VGA
  • To search application in the current proccess of linux.
ps aux | grep {appname}
  • This will kill the searched ID application in the current proccess of linux.
kill {id}
  • To check the server version linux.
lsb_release -a
  • To delete downloaded packages (.deb) already installed (and no longer needed).
apt-get clean
  • To remove unnecessary packages (after uninstalling an app there could be packages you don't need anymore).
apt-get autoremove
  • To show the real path of the running application. (ex. java)
update-alternatives --list {java}
  • To show the hard drive usage.
df
  • To show all the services available.
service --status-all
  • To change the server or local machine timezone.
dpkg-reconfigure tzdata