Basic Commands
pwd
Used to determine which directory you are in.
cd
To go to the home directory.
cd + (directory)
Name of a directory connected to the current directory. (relative path).
/
The root of the file system. (absolute path).
Navigation and File Management
ls
To look at the contents of directories.
ls -l
A much detailed one.
ls -a
To see the hidden contents at the directory.
cd + (directory_name)
Changing directory.
File and Directory Manipulation
touch
Used to create a file.
mkdir
Used to create a directory (folder).
touch filename1 filename2
To create multiple files.
mkdir foldername1 foldername2
To create multiple directory.
mkdir -p
Used to create directory inside the directory and create directory again inside the created directory.
Copying Files and Directories with "cp"
cp
Used to copy and paste file.
Ex:
cp filename Newcopyfile
Code Description: Copying file and pasting the file to the same directory.
cp -r
Used to copy Directory and paste the copied directory inside the other Directory.
Ex:
cp -r folder2 folder1
Code Description: It will create a folder2 inside the folder1.
Removing Files and Directories with "rm" and "rmdir"
rm
Used in removing files.
rmdir
Used in removing empty directories.
rm -r
Used to remove none empty directory.
rm -r + (dirname1) (dirname2)
Used to remove multiple directory.
rm *.txt
Used to delete multiple files at once.
Editing Files
nano
Used to create a file or edit a file.
nano + (existing_filename)
To edit existing file.
nano + (newfile)
To create a new file and to edit inside.
cat
To display the content of the file in the terminal.
touch
To create empty files or update timestamp
less
To open the file for viewing.
Moving and Renaming Files and Directories with "mv"
mv filenameOld filenameNew
Used in renaming file.
mv filename directoryName
Used in moving file to directory.
mv filename1 filename2 filename3 DirectoryName
Used in moving multiple file to directory.
mv DirName NewDirname
used in renaming Directory.
Note that the new name you want to use is not existing or else it will go inside the directory name(given name).
mv -n
To prevent overwriting on existing file.
mv -i
Asking first if you want to overwrtite existing file. (y) if yes and (n) for no.
In conclusion, I have learn how to see the files and directories available. I also know file manipulation commands that will allow me to view, copy, delete, or move files and directories. And also tried editing inside a file using nano text editor.
Top comments (0)