1/60
detailed 61 linux commands as curated off https://www.geeksforgeeks.org/linux-commands/?ref=gcse_outind
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
useradd
Purpose: Creates a new user account within the system.
Syntax: useradd [options] username
Options:
-m: Create the user's home directory if it does not exist.
-G: Add the user to one or more supplementary groups.
-s: Specify the login shell for the user.
-d: Set the home directory.
Example: useradd -m -G admin newuser
usermod
Purpose: Modifies the attributes and settings of an existing user.
Syntax: usermod [options] username
Options:
-g: Change the primary group for the user.
-G: Add the user to additional groups.
-d: Change the user's home directory.
-e: Set an expiration date for the user account.
Example: usermod -g users -G admin,newgroup username
userdel
Purpose: Deletes an existing user account from the system.
Syntax: userdel [options] username
Options:
-r: Remove the user's home directory and mail spool.
-f: Force the deletion of the user account even if they are logged in.
Example: userdel -r olduser
passwd
Purpose: Changes the password for a user account in the system.
Syntax: passwd [options] username
Options:
-e: Expire the user’s password immediately.
-l: Lock the user's password.
-u: Unlock a previously locked password.
Example: passwd -e username
su
Purpose: Switches the current user to a different account or to the root user.
Syntax: su [options] [username]
Options:
-: Start the shell as a login shell, simulating an initial login.
Example: su - username
groups
Purpose: Displays the groups that a specific user is a member of.
Syntax: groups [username]
Example: groups john (if no username is specified, it shows the current user's groups)
id
Purpose: Retrieves information about user and group IDs.
Syntax: id [options] [username]
Options:
-u: Display the user ID (UID) only.
-g: Display the group ID (GID) only.
Example: id username
ls
Purpose: Lists the contents of a specified directory.
Syntax: ls [options] [directory]
Options:
-l: Use a long listing format.
-a: Include hidden files in the listing.
Example: ls -la /home
cd
Purpose: Changes the current working directory in the terminal session.
Syntax: cd [directory]
Example: cd /home/user or cd .. (to go up one directory)
pwd
Purpose: Displays the full path of the current working directory.
Syntax: pwd
Example: Output might be /home/user.
mkdir
Purpose: Creates new directories in the filesystem.
Syntax: mkdir [options] directory
Options:
-p: Create parent directories as necessary.
Example: mkdir -p /home/user/newfolder
rm
Purpose: Removes files or directories from the filesystem.
Syntax: rm [options] file
Options:
-r: Recursively remove directories and their contents.
-f: Force removal without prompting for confirmation.
Example: rm -rf /home/user/oldfolder
cp
Purpose: Copies files or directories from one location to another.
Syntax: cp [options] source destination
Options:
-r: Recursively copy directories.
-p: Preserve file attributes when copying.
Example: cp -r /srcdir /destdir
mv
Purpose: Moves files or directories to a new location or renames them.
Syntax: mv [options] source destination
Options:
-i: Prompt before overwriting files.
Example: mv oldname newname
touch
Purpose: Creates an empty file or updates the timestamp of an existing file.
Syntax: touch [options] file
Example: touch newfile.txt
cat
Purpose: Displays the contents of one or more files in the terminal.
Syntax: cat [options] file
Options:
-n: Number the output lines.
Example: cat file.txt
find
Purpose: Searches for files in a directory hierarchy based on specified criteria.
Syntax: find [path] [expression]
Example: find /home -name '*.txt'
tar
Purpose: Archives files by creating a single file containing multiple files and directories.
Syntax: tar [options] archive files
Options:
-c: Create a new archive.
-f: Specify the filename of the archive.
Example: tar -cvf archive.tar /path/to/files
gzip
Purpose: Compresses files to save disk space.
Syntax: gzip [options] file
Example: gzip file.txt
gunzip
Purpose: Decompresses files that have been compressed by gzip.
Syntax: gunzip [options] file
Example: gunzip file.txt.gz
zip
Purpose: Compresses multiple files into a single zip archive.
Syntax: zip [options] archive files
Options:
-r: Recursively add files from directories.
Example: zip archive.zip file1.txt file2.txt
chmod
Purpose: Changes the access permissions of files or directories.
Syntax: chmod [options] mode file
Options:
u: User's permission.
g: Group's permission.
o: Others' permission.
Example: chmod u+x script.sh
chown
Purpose: Changes the ownership of files or directories to a specified user and/or group.
Syntax: chown [options] user[:group] file
Options:
-R: Change the ownership recursively.
Example: chown user:group file.txt
chgrp
Purpose: Changes the group ownership of a specified file or directory.
Syntax: chgrp [options] group file
Example: chgrp admin file.txt
ln
Purpose: Creates a link (hard or symbolic) to a file.
Syntax: ln [options] target link
Options:
-s: Create a symbolic link.
Example: ln -s /path/to/file linkname
grep
Purpose: Searches for a specific string or pattern in files and outputs matching lines.
Syntax: grep [options] pattern file
Options:
-i: Ignore case distinctions during matching.
Example: grep 'searchterm' file.txt
sort
Purpose: Arranges the lines of a text file in a specified order (ascending or descending).
Syntax: sort [options] file
Options:
-r: Sort in reverse order.
Example: sort -r file.txt
awk
Purpose: A scripting language for processing and analyzing text data.
Syntax: awk [options] 'pattern {action}' file
Example: awk '{print $1}' file.txt
sed
Purpose: A stream editor for basic text manipulation such as substitution, insertion, and deletion.
Syntax: sed [options] 'expression' file
Example: sed 's/original/replacement/' file.txt
cut
Purpose: Extracts specific sections from lines of files based on delimiters or byte positions.
Syntax: cut [options] file
Options:
-d: Specify the delimiter.
-f: Specify which fields to extract.
Example: cut -d',' -f1 file.txt
tr
Purpose: Translates or deletes specified characters from the input data.
Syntax: tr [options] set1 set2
Example: tr 'a-z' 'A-Z' < file.txt
echo
Purpose: Outputs a line of text or variable values to the terminal.
Syntax: echo [options] text
Example: echo 'Hello, World!'
wc
Purpose: Counts the number of lines, words, bytes, and characters in a text file.
Syntax: wc [options] file
Options:
-l: Count lines.
-w: Count words.
Example: wc -l file.txt
head
Purpose: Displays the first N lines of a file.
Syntax: head [options] file
Options:
-n: Specify number of lines to display.
Example: head -n 10 file.txt
tail
Purpose: Displays the last N lines of a file.
Syntax: tail [options] file
Options:
-n: Specify number of lines to display.
Example: tail -n 10 file.txt
ifconfig
Purpose: Configures network interfaces, displaying their current settings.
Syntax: ifconfig [options] interface
Example: ifconfig eth0
ping
Purpose: Sends ICMP echo request packets to a host to check network connectivity.
Syntax: ping [options] host
Example: ping google.com
ssh
Purpose: Securely connects to a remote server for command execution.
Syntax: ssh [options] user@host
Example: ssh user@remotehost
scp
Purpose: Securely transfers files between hosts over a network.
Syntax: scp [options] source destination
Example: scp file.txt user@remotehost:/path
wget
Purpose: Retrieves files from the web using HTTP/HTTPS protocols.
Syntax: wget [options] URL
Example: wget http://example.com/file.txt
curl
Purpose: Transfers data using various protocols, allowing uploads and downloads.
Syntax: curl [options] URL
Example: curl -O http://example.com/file.txt
df
Purpose: Displays the amount of disk space used and available on mounted filesystems.
Syntax: df [options]
Example: df -h
du
Purpose: Estimates and displays the disk space used by files and directories.
Syntax: du [options] file
Options:
-h: Display human-readable sizes.
Example: du -h /home/user
mount
Purpose: Mounts a filesystem, making it accessible at a specified directory.
Syntax: mount [options] device directory
Example: mount /dev/sda1 /mnt
ps
Purpose: Displays information about running processes, including their ID and state.
Syntax: ps [options]
Options:
-aux: Show all users' processes with detailed information.
Example: ps -aux
top
Purpose: Provides a real-time overview of system performance and running processes.
Syntax: top
Example: Simply run top to see active processes.
date
Purpose: Displays or sets the system's current date and time.
Syntax: date [options]
Example: date '+%Y-%m-%d %H:%M:%S'
cal
Purpose: Outputs a calendar for the current month or a specified date.
Syntax: cal [options]
Example: cal 2023.
shutdown
Purpose: Safely powers off the system, allowing active processes to terminate gracefully.
Syntax: shutdown [options] time
Options:
now: Shut down immediately.
Example: shutdown now
reboot
Purpose: Restarts the system, clearing active sessions and processes.
Syntax: reboot
Example: Simply run reboot.
uname
Purpose: Displays system information such as the operating system and kernel version.
Syntax: uname [options]
Example: uname -a.
history
Purpose: Shows the command history of the current user session.
Syntax: history
Example: Simply run history.
alias
Purpose: Creates shortcuts (aliases) for commands to simplify command-line operations.
Syntax: alias name='command'
Example: alias ll='ls -la'
sleep
Purpose: Pauses execution for a specified duration.
Syntax: sleep time
Example: sleep 10 (pauses for 10 seconds).
kill
Purpose: Terminates running processes using their process ID (PID).
Syntax: kill [options] PID
Options:
-9: Forcefully kill the process.
Example: kill -9 1234.
init
Purpose: The parent process for all other processes, often used for system reboot and shutdown operations.
Syntax: init [options]
Example: init 6 (to reboot the system).
man
Purpose: Displays the user manual for specific commands, providing detailed documentation.
Syntax: man [options] command
Example: man ls.
apropos
Purpose: Lists commands related to a specific keyword found within manual pages.
Syntax: apropos [keyword]
Example: apropos copy.
info
Purpose: Accesses detailed documentation in the info format, providing comprehensive command details.
Syntax: info [command]
Example: info ls.
which
Purpose: Locates the executable file associated with a command, revealing its path.
Syntax: which command
Example: which python.
whereis
Purpose: Finds the source, binary, and manual sections of a command to provide comprehensive location data.
Syntax: whereis command
Example: whereis gcc.