Common Commands

From WebHost Wiki

Jump to: navigation, search
  • ls : Lists files and directories within the current directory
  • ls -l : Lists files, permissions, owner, date modified and filesize
  • cd : Change directory.

Used as cd /home/username/public_html/ (apsolute path) or Used ad cd public_html (relative path)

  • cd ~ : Takes you to your home directory (on cpanel servers this is usually /home/username)
  • cd ../ : Takes you to the directory above you.
  • cat filename : shows the contents of filename.
  • chmod : Change file access permissions for USER - GROUP - EVERYONE.
    • 0 = — No permission
    • 1 = –X Execute only
    • 2 = -W- Write only
    • 3 = -WX Write and execute
    • 4 = R– Read only
    • 5 = R-X Read and execute
    • 6 = RW- Read and write
    • 7 = RWX Read, write and execute
  • Example Usage:
    • chmod 777 filename
    • This gives the USER, GROUP and EVERYONE Read, Write and Execute permissions for the file named filename.
  • Common Usage
    • chmod 000: No-one can access the file
    • chmod 644 : Default for most files
    • chmod 755 : Used for CGI scripts and directories
    • chmod 777 : Usually used if you want a script to write to a file
  • pico : Easy to use file editor.
    • Used as follows: pico filename
  • grep : Looks for patterns within files.
    • Used as follows: grep “what your looking for” /file/location or
    • Used as: cat /proc/cpuinfo | grep “vendor_id” this would show the line that shows the vendor_id within the file /proc/cpuinfo.
  • last : shows the last users that logged in. Can also use last -20 -a which would show the last 20 logins with hostnames
  • w : shows users that are logged in with where they are logged in from
  • who : Shows who is on the server in a shell
  • users : Shows users logged into shell
  • netstat : Shows all current network connections
  • top : Shows all live system processes, uptime, memory stats etc.. (The processes are show in a style similar to the Windows Task Manager).
  • touch : Creates an empty file.
    • Used as follows: touch /path/to/where/you/want/the/file/filename.html
  • du -sh : Shows disk usage in a readable format.
  • cp filename filename.copy : Would copy the file filename to filename.copy So there would now be 2 files called filename and filename.copy.
  • mv filename newdir/filename : Would move filename to the the directory named newdir. You can also change the destination filename to something diferent, so for example mv filename newdir/filename2 would move filename into newdir, and rename it filename2.
  • rm filename : Remove/Delete file called filename.
  • tar : Creating and Extracting tar and tar.gz files
    • Usage:
    • tar -zxvf file.tar.gz : Extracts the file file.tar.gz (Gzipped)
    • tar -xvf file.tar : Extracts the file file.tar (Not Gzipped)
  • tar -cf archives.tar directory/ : Takes everything from directory/ and puts it into archives.tar
  • unzip filename.zip : Extracts filename.zip into the current directory.
  • zip filename.zip filename : Zip filename into a zip file called filename.zip
  • logout : closes the session.
  • exit : exits the session (basically the same as logout)
Personal tools