Linux Commands and Shortcut
Linux Commands and Shortcut
{01}Linux Interface
 Users commonly interact with a UNIX system via a text-based
  command-line interface.
 In a terminal, commands are entered at a prompt and results
  are displayed.
 UNIX systems also provide a graphical interface similar to
  those of the Macintosh and Windows platforms.
<Lesson>
This is the physical hardware, like   The desktop environment sits on    The window manager controls the
the monitor, graphics card, mouse,    top of the X Window System and     appearance and behavior of
and keyboard, which the graphical     window manager. It provides a      windows. It allows users to move,
interface interacts with.             more integrated user experience,   resize, and close windows.
                                      complete with file managers,       Examples       include   Openbox,
                                      icons, panels, and other user-     Compiz, and Mutter. Users can
                                      friendly tools. Popular desktop    replace the window manager
                                      environments in UNIX include       without changing the entire
                                      GNOME, KDE Plasma, and XFCE.       graphical interface.
<Lesson>
                                                                          Operating System
     Applications                         X-Windows                           (Kernel)
These are the graphical programs    The X Window System provides       The kernel controls hardware
that users interact with, such as   the foundation for graphical       interactions and provides low-level
web browsers, text editors, and     environments in UNIX. It manages   access to system resources. It
media players, all running within   windows, handles user input        ensures the graphical interface can
the framework provided by the       (keyboard and mouse), and          communicate with hardware like
layers beneath them.                provides network transparency,     the display and input devices
                                    meaning it can display programs
                                    running on remote systems.
<Lesson>
           0 The Terminal
              You need a terminal window, which runs a program called a
           2   shell
              Open a terminal window from the “Applications” menu,
               under “Activities” or by searching for “Terminal”.
[username@lisp ~]$
           0 The Terminal
                The prompt gives you information about the account and
           LINUX
           COMMAND
<Lesson>
           touch   Create an empty file or update file                                              touch file.txt – Creates an empty file
                              timestamps                                                                       named “file.txt”
            cat        View the contents of a file                                                cat file.txt – displays the contents of the
                                                                                                                  file “file.txt”.
           head    Displays the first few lines of a file   -n – Specify the number of lines to   head file.txt – shows the first 20 lines of
                                                                           display                                  the file.
                                                                                                   Head –n 5 file.txt- displays the first 5
                                                                                                               lines of the file.
<Lesson>
            ln        Create links between files             -s – creates symbolic (soft) links.      ln –s source_file link_name – creates a
                                                                                                         symbolic link named “link_name”
                                                                                                              pointing to “source_file”
           find    Search for files and directories            -name – serach by file name              find/path/to/search-name”*.txt” –
                                                                -type – search by file type           Searches for all files with the extension
                                                                                                          “.txt” in the specified directory.
<Lesson>
           chown      Change file owneshp                                          chown user file.txt – Changes the owner
                                                                                      of “file.txt” to the specified user.
           chgrp    Change group ownership                                         chgrp group file.txt – changes the group
                                                                                    ownership of “file.txt” to the specified
                                                                                                    group.
           umask   Set default file permissions                                       umask 022- sets the default file
                                                                                    permissions to read and write for the
                                                                                     owner and read-only for group and
                                                                                                   other.
<Lesson>         AGUSTIN
           gzip                    Compress files.                   -d – Decompress files                gzip file.txt – compresses the file
                                                                                                      “file.txt” and renames it as “file.txt.gz”.
           zip             Creatw compressed zip archives     -r – recursively include directories    zip archive.zip file1.txt file2.txt – creates
                                                                                                                  zip archive named
                                                                                                       “archive.zip”containing “file1.txt” and
                                                                                                                       “file2.txt”.
<Lesson>
Process  Management
     Command
                          Commands
                  Description                                           Options                                Examples
            ps            Display running processes            -aux – Show all rocesses          ps aux – shows all running processes
                                                                                                      with detailed information.
            top    Monitor system processes in real – time.                                    top – displays a dynamic view of system
                                                                                                 processes and their resource usage.
            kill             Terminate a process              -9 – forcefully kill a process   kill PID – Terminates the process with the
                                                                                                           specified process ID
           pkill    Terminates processes based on their                                          pkill process_name – terminates all
                                  name                                                           processes with the specified name.
           pgrep     List processes based on their name                                        pgrep process_name – list all processes
                                                                                                      with the specified name
<Lesson>
Process
     CommandManagement
                    DescriptionCommandsOptions                                                                            Examples
       grep       Used to search for specific patterns          -i: Ignore case distinctions while                   grep -i “hello” file.txt
                  or regular expressions in text files or                      searching.                           grep -v “error” file.txt
                  streams and display matching lines.          -v: Invert the match, displaying non-             grep -r “pattern” directory/
                                                                             matching lines.                      grep -l “keyword” file.txt
                                                            -r or -R: Recursively search directories for           grep -n “pattern” file.txt
                                                                           matching patterns.              In these examples we are extracting our
                                                                   -l: Print only the names of files        desired output from filename (file.txt)
                                                                          containing matches.
                                                                 n: Display line numbers alongside
                                                                             matching lines.
                                                            -w: Match whole words only, rather than
                                                                            partial matches.
                                                             -c: Count the number of matching lines
                                                                      instead of displaying them.
                                                              -e: Specify multiple patterns to search
                                                                                   for.
                                                             -A: Display lines after the matching line.
                                                            -B: Display lines before the matching line.
                                                              -C: Display lines both before and after
                                                                           the matching line.
<Lesson>
           du      Estimate file and directory sizes.   -h: Human-readable sizes.                      du -sh directory/
                                                        -s: Display total size only.         provides the total size of the specified
                                                                                                           directory.
Networking
        Command
               CommandsDescription                                         Examples
Networking Commands
       Command               Description                               Examples
           scp    Securely copy files between hosts.                  scp file.txt
                                                       user@hostname:/path/to/destination
                                                       securely copies “file.txt” to the specified
                                                                     remote host.
IO Redirection Commands
             Command                            Description
             Cmd < file               Input of cmd is taken from file
             cmd > file      Standard output (stdout) of cmd is redirected to
                                                  file.
             Cmd 2> file     stderr is redirected to the same place as stdout.
           cmd1 <(cmd2)      Output of cmd2 is used as the input file for cmd1.
           cmd > /dev/null    Discards the stdout of cmd by sending it to the
                                               null device.
             cmd &> file         Every output of cmd is redirected to file.
             cmd 1>&2         stdout is redirected to the same place as stderr.
             cmd >> file            Appends the stdout of cmd to file.
<Lesson>
           sudo adduser username      Create a new user account on the system with the specified
                                                             username.
                    Finger            Display information about all the users currently logged into
                                         the system, including their usernames, login time, and
                                                                terminal.
      sudo deluser USER GROUPNAME         Remove the specified user from the specified group.
Shorcut Commands
Bash Shortcut Commands
            Navigation                Description
VI Shortcuts Commands
           Command                              Description
VI Shortcuts Commands
           Command                               Description
4dw Delete the next four words from the cursor position.
3dd Delete the current line and the two lines below it.
              C          Delete from the cursor position to the end of the line and
                                          switch to insert mode.
<Lesson>
:q! Quit Vim without saving changes. D Delete the selected text.
         :wq               Save and quit Vim.               P        Paste the copied or deleted text
          or
         :x:x
        :set nu
           or
     :set numbe          Display line numbers.
<Lesson>
Thank You!