Useful Terminal commands Print Working Directory. pwd will display your current directory ei. /home/username Concatenate. Can be used to show you the content of a file. cat filename Concatenates the contents of the specified file to the end of a new file. cat file > newfile pres ctl + d when you are done. Copy copy filename.txt to Documents folder. cp filename.txt /home/username/Documents -r directory1 directory2 copies the directory directory1 and all of its contents to a new directory named directory2 in the current directory. Move files or rename them. mv filename.txt /home/username/Documents This will move filename.txt to Documents. mv directory1 directory2 Moves the directory directory1 to a new directory named directory2 in the current directory. Make Directory. The mkdir command is a essential tool for organizing your files and directories. Create new directories in the current directory. mkdir mydirectory Creates 3 directories in the current directory ( Documents , images, videos ) mkdir documents images videos Creates a new directory named mydirectory with two subdirectories named subdir1 and subdir2 mkdir -p mydirectory/subdir1/subdir2 Remove Directory(use with caution). Remove the empty directory named mydirectory in the current directory.
The dir command is a good alternative to the ls command, which is the more common command for listing directory contents in Linux. The dir command produces a more readable output than the ls command, especially when displaying long filenames and file permissions. Change Directory cd /home/user/Documents/Project - Changes to the Project directory in the Documents directory. cd .. - Changes to the parent directory of the current directory. Change to the previous directory. Global Regular Expression Print. grep "Hello, world!" filename.txt clear
Chown - Change ownership of files and directories. Allows you to set the owner and group for files and directories. ln - Symbolic link is a type of file that points to another file or directory. Useful when setting up Web servers or FTP servers. To create a symbolic link named shortcut that points to a directory To remove a symbolic link, you can use the unlink command or rm. unlink shortscut |
Comments