Sei sulla pagina 1di 3

 whoami are the accessed user accounts, the terminal name it is  ls -R will will display also the contents

also the contents of sub-directories


opened and the last date and time it is accessed.  ls --version checks the version of the ls command.
 who in linux is the name of the active user.  clear is the command to clear your terminal of any previous syntax
 w command tells about the users who are logged in and what are  The cd stands for 'change directory' and this command is used to
they doing change the current directory i.e; the directory in which the user is
 id command tells about your user id, primary group id, and a list of currently working. To change directory, the syntax is cd <directory>
groups that belongs to you wherein directory is the folder you want to open. You can check the
 passwd is the command for changing the password of current user folders, files you can open in your current directory by using the ls
 pwd keyword (print working directory) command displays your command.
location currently you are working on. It will give the whole path  You can change the destination using absolute path. Absolute path
starting from the root ending to the directory. It answers the question, has to mention whole path starting from root. In changing destination
where is your current directory. using absolute path, the path should be correct or else an error will
 ls is the list command in Linux. It will show the full list or content of occur. Each directory is separated by /. “cd Desktop/Folder1/Folder2”
your directory. It answers the question, what is inside your current  mkdir stands for 'make directory'. With the help of mkdir command,
directory you can create a new directory wherever you want in your system.
 ls -a In Linux, hidden files start with . (dot) symbol and they are not  rmdir command is used to delete a directory. But will not be able to
visible in the regular directory. The (ls -a) command will enlist the delete a directory including a sub-directory. It means, a directory has
whole list of the current directory including the hidden files. to be empty to be deleted.
 ls -r will display the list in reverse order  file * is used to list types of all the files.
 ls -l will show the list in a long list format.  file <filename> will display the file type and details; where filename
a string variable of the name of the file (with its extension)
 ls -lh will show you the file sizes in human readable format. Size of  file [range]* It will list out all the files starting from the alphabet
the file is very difficult to read when displayed in terms of byte. The present within the given range. File [a-m]* will display all files
(ls -lh) command will give you the data in terms of Mb, Gb, Tb, etc. alphabetically that starts with letter a to m
 touch -t YYYYMMDDhhmm.ss <filename1> will create a file
 ls --color=never and ls --color=auto are both styles in displaying the
<filename> by specifying the time. Wherein YYYY is the year, MM is
list in the directory. the month, DD is the date, hh is the hour, mm is the minutes, and ss
 ls ~ gives the content of the home directory are the seconds.

 ls ../ gives the content of the parent directory


 touch -a <filename> command with option 'a' is used to change the  cp *.<extension> <destinationDirectory> is a command to copy
access time of a file. By default, it will take the current time of your multiple files into a destination at once. Wherein extension is the file
system. extensions to be copied, while destinantionDirectory is the name of
 touch -m <filename> command will help you to change only the the directory where the duplicate will be saved.
modification time of a file  cp -i <filename> <destinationDirectory> allows you to confirm once
 touch -r <filename1> <filename2> command will update time with before overwriting your file. Wherein filename is the name of the file
reference to the other mentioned command. The time of filename1 to be copied, while the destinationDirectory is the name of the
will be updated with the reference time of filename2. directory where the duplicate file will be saved.
 rm <filename> This command is used to remove a file.  cp -p <filename> <destinationDirectory> allows you to preserve
 rm *<file extension> used to remove all the files ending with same the properties and attributes of a file. Wherein filename is the name
extensions. Wherein extension is a string variable of file extensions of the file to be copied, while the destinationDirectory is the name of
like .pdf, .txt, .odt, .png, etc. the directory where the duplicate file will be saved.
 rm -r <dirname> delete a directory having sub directories inside it.  cp -u -v <filenames> <destinationDirectory> command is used
So you don't need to delete sub-directories manually. when you want to make sure that destination file is missing or doesn't
 The option 'i' stands for 'interactivity'. Before deleting a file it will ask exist. Wherein filename is the name of the file to be copied, while the
you whether you want to delete it or not. To delete a file use command destinationDirectory is the name of the directory where the duplicate
rm -i <filename> and to delete a directory use command rm -ri file will be saved.
<directory>  mv <filename> <newname> is used to move existing file or directory
 The option ‘f’ in rm command deletes directory forcefully. It means a from one location to another. It is also used to rename a file or
file or directory will be deleted anyhow even if it has read-only directory. Wherein filename is the name of a file while newname is a
permission. To delete a file forcefully, use command rm -f newname of the file.
<filename>. To delete a directory forcefully, use command rm -rf  mv -i <filename> <newname> will ask for permission first before
<directory>. overwriting it. If you want to copy a file using 'mv' option and if that file
 cp <sourcename> <newname> is used to copy a file or directory. already exists then it will silently over write the existing file. But if you'll
Wherein sourcename is the file to be copied, while newname is the use 'i' option then it will first ask for your permission to over write it.
name of the duplicate file Wherein filename is the name of a file while newname is a newname
 cp <sourcename> <directory> is the command to copy a file into a of the file.
different directory. Wherein sourcename is the string variable of the  The head <file name> command displays the starting content of a
file to be copied, while directory is the string variable of the name of file. By default, it displays starting 10 lines of any file. The head <file
the directory where the file will be copied name> <file name> command is use If we'll write two file names then
 cp -r <sourceDirectory> <destinationDirectory> is a command to it will display first ten lines (in this case file has five lines only) of each
copy a directory and all its content to another directory. Wherein file separated by a heading.
sourceDirectory is the directory to be copied with all its contents,  The head -n <number> <file name> displays specified number of
whole destinationDirectory is the name of the directory where the lines.
duplicate will be saved.  The head -c <number> <file name> displays counts the number of
bytes of a file. If you'll use head -c<number>k <file name> then it
will return the result by multiplying the number by suffix. Suffix can be
"b (bytes=512), k(kilobytes=1024) and m (megabytes=1048576)".
 The tail <file name> The 'tail' command displays the last lines of a
file. Its main purpose is to read the error message. By default, it will
also display the last ten lines of a file
 The tail -n <number> <file name> displays specified number of lines
from the last.
 The tail -c <number> <file name> displays the specified number of
bytes from the last
 The 'cat' command is the most universal and powerful tool. It is
considered to be one of the most frequently used command.
 The cat <fileName> can be used to display the content of a file.
 The cat > <fileName> command can be used to create a new file
with greater than sign
 The cat >> <file name> command with double greater than
sign (>>) append (add something in the last of a file) something in
your already existing file.
 cat <olderFilename> > <newerFilename> command can be used
to copy the content of a file into another file.
 cat <filename1> <filename2>.... > <newFilename> command can
be used to concatenate contents of multiple files in a single new file.
 cat - <filename1> <filename2>..> <newFilename> command
means a new line will be inserted while concatenating multiple files.
 cat -n <fileName> displays line numbers in front of each line in a file
 cat -b <fileName> option removes the empty lines.
 cat -e <fileName> option displays '$' sign at the end of every line
 cat > <filename> << EOF option displays end marker at the end of a
file. This is called here directive and file content will be saved at the
given end marker. Any word other than 'EOF' can be used for the end
marker.

Potrebbero piacerti anche