Linux commands

From ElectroDragon
Jump to: navigation, search

File/Folder operation

Command Description example
cp copy file cp -r folder /home/
rm -rf remove the file or folder, r=? f=force -
mv move or rename files and folders mv /usr/lib/* /zone

File/Folder Rights

Command command description example example description
chown change folder owner and group chown -R oracle:oinstall /home/pi oracle is user, oinstall is group
chmod change folder/file permission chmod -R 700 /opt/oracle 700 is the permission, R means folder and files, recursive
usermod -a -G Add the user to the supplementary group(s). Use only with the -G option. usermod -a -G pi debian-transmission add debian* to pi group
chgrp change group
  • chgrp debian-transmission /mnt/usbel/Torrents/mytrasnmission/incomplete
  • chgrp debian-transmission /mnt/usbel/Torrents/mytrasnmission/complete
change folder group



  • alias:set alias name for command, alias p="pwd" or p='pwd'
  • add alias on boot: ~/.bashrc for single user
  • or /etc/bashrc or /etc/bash.bashrc for all user (ubuntu, lubuntu)
  • reboot to make it work.

Linux System file

  • cat /var/log/kern.log kernal log
  • cat /proc/cpuinfo cpu info
  • nano /etc/passwd edit users
test:x:503:503::/home/test:/bin/bash // set the user: login name, password, ID, groupID, comment paragraph, main directory, shell, etc
  • nano /etc/group edit groups
debian-transmission:x:117:root,pi // user root and pi are in group debian-transmission
  • /etc/hosts hosts file


  • ping, ping ip address
  • ifconfig: show network info
  • user and group commands: id, whoami, groups, passwd, su switch user, sudo get root right
  • rsync -azv /var/opt/installation/inventory/ /root/temp/
Command Description example Result Explanation Type
wget download a file from internet - - - internet
apt-get install, remove, update, remove --purage package - - - package
sudo dpkg -i debfile install *.deb package - - - package
Usermod -G add user to a group usermod -G root pi add user pi to root group - user
groups <user> check user in which group groups root root : root indiecity debian-transmission - group
su switch user - - - user
groupadd or groupdel add/del new group groupadd group1 Group
ls -l list the user and group ls -l drwxrwxr-x 1 root root 8192 Nov 10 03:18 SSK 3th root = user, 4th root =group, SSK folder name Ls
chown - chown root:debian-transmission SSK set user root and group debian-transmissoin for folder SSK - Auth
pwd list current folder - - - info
df check the size of disk df -h - human read info
du check size of folders du -sh /* - -h human read -s conclusion info
cat print file content to screen - - - info
* tailf diplay the last 10 lines of the file tailf /srv/www/logs/www*access.log - - info
lsusb, lsmod list usb, modules - - - system info
dmesg Boot info - - - system info
crontab -e run programme periodically - - - system
help help command - - - system
man show manual man update-rc.d - - system
ps -x show current process - - - system
top system status - - - system
hostname show/edit hostname hostname - - system
hostname show/edit hostname hostname moon change hostname to "moon", also need to change /etc/hosts - system
free -m check free memory #total: Total memory size;
#used: memory has been used;
#free: free memory;
#shared: shared memory size;
#buffers: used for buffer memory;
#cached: used for cache memory
- - system


  1. 0 0 * * * rm -rf /tmp/motion/*.* # rm all the files in motion folder at 0:0
  2. 0 */2 * * * /sbin/service httpd restart # restart httpd every two hours