Basic Commands

cat: Sends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping. Syntax: cat FILENAME. Ex: cat abc (Tells you the content of file abc).

cd: Change directory. Syntax: cd /PATH. Ex: cd /home (Change the current working directory to /home. The '/' indicates relative to root, and no matter what directory you are in when you execute this command, the directory will be changed to "/home").
  • cd ..: Move to the parent directory of the current directory. This command will make the current working directory "/home".
  • cd ~: Move to the user's home directory which is "/home/username". The '~' indicates the users home directory.
cp: Copy files. Syntax: cp SOURCE DESTINATION. Ex: cp abc def (This will copy a file abc to def in the same folder).
  • cp -i abc def: (With the "-i" option, if the file "def" exists, you will be prompted before it is overwritten).
  • cp -i /home/abc .: (Copy the file "/home/abc" to the current working directory and name it "abc". Prompt before overwriting the file).
  • cp -dpr SRC_DIR DEST_DIR: (Copy all files from the directory "SRC_DIR" to the directory "DEST_DIR" preserving links (-p option), file attributes (-d option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another directory.
df: Show the amount of disk space used on each mounted filesystem.

less: Similar to the more command, but the user can page up and down through the file. Ex: less acb (The example displays the contents of abc).

ln: Creates a symbolic link to a file.
  • ln -s ABC XYZ: Creates a symbolic link named XYZ that points to the file ABC.
  • ls -i ABC XYZ: Show the two files are different with different inodes. 
  • ls -l ABC XYZ: Show that XYZ points to the file ABC.
locate: To locate file or any binaries.

logout: Logs the current user off the system.

ls: List files
  • ls: List files in the current working directory except those starting with . and only show the file name.
  • ls -al: List all files in the current working directory in long listing format showing permissions, ownership, size, and time and date stamp
  • more: Allows file contents or piped output to be sent to the screen one page at a time.
  • more /etc/profile: Lists the contents of the "/etc/profile" file to the screen one page at a time.
  • ls -al |more: Performs a directory listing of all files and pipes the output of the listing through more. If the directory listing is longer than a page, it will be listed one page at a time.
mv: Move or rename files
  • mv -i ABC DEF: Move the file from "ABC" to "DEF". This effectively changes the name of "ABC" to "DEF".
  • mv -i /home/ABC .: Move the file from "/home" to the current working directory.
pwd: Show the name of the current working directory

shutdown: Shuts the system down.
  • shutdown -h now: Shuts the system down to halt immediately.
  • shutdown -r now: Shuts the system down immediately and the system reboots.
whereis: Show where the binary, source and manual page files are for a command.
  • whereis ls: Locates binaries and manual pages for the ls command.
who: Shows which users are logged in.

w: Shows which users are logged in with information as USER, LOGIN@, IDLE, JCPU, PCPU, WHAT.

hostname: The name of your machine.

Comments

Popular posts from this blog

Installing Tomcat8 on RHEL6

Manage existing resources via Helm

Configuration and setting-up of AIDE on RHEL6