Essential Linux Commands: A Quick Reference
Essential Linux Commands
File and Directory Management
- cd – Change directory. Example:
cd /home/user
(Navigates to the /home/user directory) - mkdir – Create a directory. Example:
mkdir /home/user/new_directory
(Creates a new directory) - ls – List directory contents. Example:
ls /home/user
(Lists files and directories in /home/user) - cp – Copy files. Example:
cp /home/user/file1.txt /home/backup
(Copies file1.txt to /home/backup) - mv – Move files. Example:
mv /home/user/file1.txt /home/new_location
(Moves
Essential Linux Commands and Security Features
Essential Linux Commands
1. mkdir (Make Directory)
The mkdir
command is used to create one or more new directories.
Syntax:
mkdir [options] directory_name
Examples:
- Create a single directory:
mkdir myfolder
- Create nested directories using the
-p
option:mkdir -p parent/child/grandchild
- Create multiple directories at once:
mkdir dir1 dir2 dir3
2. cat (Concatenate and Display Files)
The cat
command is used to view the contents of a file, create a file, or concatenate multiple files.
Syntax:
cat [options] [file_name(
Read More
Essential Unix Commands for File and Directory Management
Copy a File
- cp source destination
- Where source and destination are filenames and may need to refer to full pathnames.
- Has the effect of copying file source to a new file destination
- cp source .
- Has the effect of copying file source into the current directory – the . is shorthand for “here”.
Remove/Delete a File
- rm file
- Use this command with caution – files deleted in this way cannot be retrieved.
Rename (Move) a File
- mv source destination
- Moves the file source to a new file destination.
- As well as renaming
Linux Command Line: Essential Operations and Scripting
1. Relationships:
- 1: fg% 3-D – Mounted disk
- 2: B – gzip-compressed
- 3: unmount – Nothing
- 4: mke3fs -C – Format
- 5: tar – Nothing
- 6: dd if-E – To back up
- 7: bg% 3 -F – Passing the task
- 8: tar cvf-A – To package
2. Commands:
- A: 2 + 2 =
expr 2 + 2
- B: Change user password:
passwd ana
- C: Shut down computer:
shutdown -h now
- D: Change ownership of ejer60 to user antonio:
chown antonio ejer60
- E: Delete all files:
rm *
- F: Change the file name:
mv script52 ejer52
- G: Copy all files starting with “exercise” to the “Exercise”
Linux Commands and File System Management
Essential Linux Commands and File Management
ULI101: Introduction to UNIX/Linux and the Internet – Week 1, Lesson 2
Basic Linux Command Structure
- Command Format:
command argument1 argument2 ...
- Examples:
pwd
: Display current directory.date
: Show current date and time.ls
: List files in the current directory.ls /etc
: List files in/etc
directory.ls -l
: Detailed file listing in the current directory.ls -l /etc
: Detailed file listing in/etc
directory.
- Examples:
Getting Help with Commands
man command
: View manual for