linux commands

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/60

flashcard set

Earn XP

Description and Tags

detailed 61 linux commands as curated off https://www.geeksforgeeks.org/linux-commands/?ref=gcse_outind

Last updated 2:28 PM on 2/7/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

61 Terms

1
New cards

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

2
New cards

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

3
New cards

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

4
New cards

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

5
New cards

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

6
New cards

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)

7
New cards

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

8
New cards

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

9
New cards

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)

10
New cards

pwd

  • Purpose: Displays the full path of the current working directory.

  • Syntax: pwd

  • Example: Output might be /home/user.

11
New cards

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

12
New cards

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

13
New cards

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

14
New cards

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

15
New cards

touch

  • Purpose: Creates an empty file or updates the timestamp of an existing file.

  • Syntax: touch [options] file

  • Example: touch newfile.txt

16
New cards

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

17
New cards

find

  • Purpose: Searches for files in a directory hierarchy based on specified criteria.

  • Syntax: find [path] [expression]

  • Example: find /home -name '*.txt'

18
New cards

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

19
New cards

gzip

  • Purpose: Compresses files to save disk space.

  • Syntax: gzip [options] file

  • Example: gzip file.txt

20
New cards

gunzip

  • Purpose: Decompresses files that have been compressed by gzip.

  • Syntax: gunzip [options] file

  • Example: gunzip file.txt.gz

21
New cards

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

22
New cards

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

23
New cards

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

24
New cards

chgrp

  • Purpose: Changes the group ownership of a specified file or directory.

  • Syntax: chgrp [options] group file

  • Example: chgrp admin file.txt

25
New cards

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

26
New cards

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

27
New cards

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

28
New cards

awk

  • Purpose: A scripting language for processing and analyzing text data.

  • Syntax: awk [options] 'pattern {action}' file

  • Example: awk '{print $1}' file.txt

29
New cards

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

30
New cards

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

31
New cards

tr

  • Purpose: Translates or deletes specified characters from the input data.

  • Syntax: tr [options] set1 set2

  • Example: tr 'a-z' 'A-Z' < file.txt

32
New cards

echo

  • Purpose: Outputs a line of text or variable values to the terminal.

  • Syntax: echo [options] text

  • Example: echo 'Hello, World!'

33
New cards

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

34
New cards

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

35
New cards

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

36
New cards

ifconfig

  • Purpose: Configures network interfaces, displaying their current settings.

  • Syntax: ifconfig [options] interface

  • Example: ifconfig eth0

37
New cards

ping

  • Purpose: Sends ICMP echo request packets to a host to check network connectivity.

  • Syntax: ping [options] host

  • Example: ping google.com

38
New cards

ssh

  • Purpose: Securely connects to a remote server for command execution.

  • Syntax: ssh [options] user@host

  • Example: ssh user@remotehost

39
New cards

scp

  • Purpose: Securely transfers files between hosts over a network.

  • Syntax: scp [options] source destination

  • Example: scp file.txt user@remotehost:/path

40
New cards

wget

  • Purpose: Retrieves files from the web using HTTP/HTTPS protocols.

  • Syntax: wget [options] URL

  • Example: wget http://example.com/file.txt

41
New cards

curl

  • Purpose: Transfers data using various protocols, allowing uploads and downloads.

  • Syntax: curl [options] URL

  • Example: curl -O http://example.com/file.txt

42
New cards

df

  • Purpose: Displays the amount of disk space used and available on mounted filesystems.

  • Syntax: df [options]

  • Example: df -h

43
New cards

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

44
New cards

mount

  • Purpose: Mounts a filesystem, making it accessible at a specified directory.

  • Syntax: mount [options] device directory

  • Example: mount /dev/sda1 /mnt

45
New cards

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

46
New cards

top

  • Purpose: Provides a real-time overview of system performance and running processes.

  • Syntax: top

  • Example: Simply run top to see active processes.

47
New cards

date

  • Purpose: Displays or sets the system's current date and time.

  • Syntax: date [options]

  • Example: date '+%Y-%m-%d %H:%M:%S'

48
New cards

cal

  • Purpose: Outputs a calendar for the current month or a specified date.

  • Syntax: cal [options]

  • Example: cal 2023.

49
New cards

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

50
New cards

reboot

  • Purpose: Restarts the system, clearing active sessions and processes.

  • Syntax: reboot

  • Example: Simply run reboot.

51
New cards

uname

  • Purpose: Displays system information such as the operating system and kernel version.

  • Syntax: uname [options]

  • Example: uname -a.

52
New cards

history

  • Purpose: Shows the command history of the current user session.

  • Syntax: history

  • Example: Simply run history.

53
New cards

alias

  • Purpose: Creates shortcuts (aliases) for commands to simplify command-line operations.

  • Syntax: alias name='command'

  • Example: alias ll='ls -la'

54
New cards

sleep

  • Purpose: Pauses execution for a specified duration.

  • Syntax: sleep time

  • Example: sleep 10 (pauses for 10 seconds).

55
New cards

kill

  • Purpose: Terminates running processes using their process ID (PID).

  • Syntax: kill [options] PID

  • Options:

    • -9: Forcefully kill the process.

  • Example: kill -9 1234.

56
New cards

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).

57
New cards

man

  • Purpose: Displays the user manual for specific commands, providing detailed documentation.

  • Syntax: man [options] command

  • Example: man ls.

58
New cards

apropos

  • Purpose: Lists commands related to a specific keyword found within manual pages.

  • Syntax: apropos [keyword]

  • Example: apropos copy.

59
New cards

info

  • Purpose: Accesses detailed documentation in the info format, providing comprehensive command details.

  • Syntax: info [command]

  • Example: info ls.

60
New cards

which

  • Purpose: Locates the executable file associated with a command, revealing its path.

  • Syntax: which command

  • Example: which python.

61
New cards

whereis

  • Purpose: Finds the source, binary, and manual sections of a command to provide comprehensive location data.

  • Syntax: whereis command

  • Example: whereis gcc.