Here are some useful linux commands...
- whoami - This command gives you the userid you are logged in as
- pwd - print working directory. When you type in this command it tells you which folder you are in and along with printing the path of the folder
- ls - listing. This command will list out all the files and directories under the current directory sorted alphabetically
- ls -F - This command lists all the files and directories with directories displayed with a trailing slash and executables have a * at the end of the executable name
- ls -s - lists file sizes - displays in disk blocks
- ls -s -h lists file sizes with human readable file sizes
- wc - word count displays lines, words, characters for a particular file
- wc -c
- wc -w
- wc -l
- cat - concatenate - prints the file contents one after another
- sort - sorts the output
- head -
- gets the topN results from a file - mv - move - moves a file
- cp - copy - copies a file
- rm - removes a file
- rmdir - removes a directory
- cd - change directory: users can change the directory or rather navigate
- .. - special file - goes to the parent directory
- ls -a - show all - lists the hidden files too
- . - special file - gets the current directory
- mkdir - make directory. Creates a new directory under the current directory
- split - splits a given file according to the argument provided
- If no argument given to this command it creates a new file with the same contents in the current directory
- split -l 1
- splits the given file with one line of the file in a separate file thus if the given file has 3 lines after using above command there will be three separate files - Permission x on a file means the file is an executable but then x on a directory means that the directory can be TRAVERSED - which means we can look at the contents of the directory
- chmod - change mode
- chmod u=rwx - user gets read, write, execute permissions
- chmod g=rwx - group gets read, write, execute permissions
- chmod a=rwx - all get read, write, execute permissions
- chmod a= - all get no permissions on the file - removes all the permissions on the file
- You can combine two commands and run them as one using semi colon. For Ex: chmod u=r
; ls -l - this will change the user permissions for the file name given to read and then display the list of files/directories under the current directory
Comments