Monday, November 16, 2009

Linux Commands - basic commands

* ls - files in the current directory.
* cd - working directory. If your current path is /home/username/Trash for instance, typing "cd" will bring you back to /home/username.
* mkdir - a new directory
* rmdir - a directory (must be empty)
* touch - "touch filename" create a new file "filename".
* cp - such as "cp currentFile newFile", and is used to copy files.
* diff - compares two files, "diff file1 file2" compares each line of file1 and file2, displays the difference.
* mv - such as "mv currentLocation newLocation". This is used to either move or rename files.
* rm - such as "rm myFile"; it is used to delete files permanently. "rm -r existingdir" will remove the existing directory named 'existingdir' and all directories and files below it.
* ln - create a shortcut. For example "ln -s orignial symlink" create a symbolic file "symlink" pointing to the file "original"
* pwd - the working (current) directory.
* cat - files (can be used to join them together), and prints its output to standard output (the terminal screen). Used like: "cat myFile".
* less - for file viewing in the shell, and is most useful for text files; invoked like "less myFile".
* tail - show the last 10 lines of a file, and is very useful to view a updating file. For example: "tail -f /var/log/messages" shows the last 10 lines of changing log file messages.
* whereis - show where the binary, source and manual page files are for a command. For example "whereis ifconfig".
* find - be used to find files via the command line. Example usage could be: "find . -name toc", which looks at the current directory (defined by ".") for any files with the name "toc".
* grep - be used to find lines contains a specific pattern. For example : "grep root /etc/passwd" find all lines contains string "root" in the file passwd.
* date - the current date! This can also be used to set the date of the system (but administrator privileges are required).For example: # date -s "2 OCT 2006 18:00:00"
* history - in shell command for the BASH environment that shows the last run commands.

No comments:

Post a Comment

chatgpt's view about universe

 is there god? The existence of a higher power, commonly referred to as "God," is a matter of personal belief and faith. There is ...