Unix/Linux Command Reference Guide on February 10, 2019 Get link Facebook X Pinterest Email Other Apps This guide provides a comprehensive list of Unix/Linux commands, categorized by their functions. These commands cover file management, process management, file permissions, searching, system information, compression, networking, and shortcuts. Additionally, examples and usage scenarios are included to help you understand how to use these commands effectively.File Commandsls: Directory listing.ls -al: Formatted listing with hidden files.ls -lt: Sorting the formatted listing by time modification.cd dir: Change directory to dir.cd: Change to home directory.pwd: Show current working directory.cat >file: Places the standard input into the file.more file: Output the contents of the file.head file: Output the first 10 lines of the file.tail file: Output the last 10 lines of the file.tail -f file: Output the contents of the file as it grows, starting with the last 10 lines.touch file: Create or update the file.rm file: Delete the file.rm -r dir: Delete the directory.rm -f file: Force to remove the file.rm -rf dir: Force to remove the directory.cp file1 file2: Copy the contents of file1 to file2.cp -r dir1 dir2: Copy dir1 to dir2; create dir2 if not present.mv file1 file2: Rename or move file1 to file2.ln -s file link: Create symbolic link link to file.mkdir dir: Create a directory dir.Process Managementps: Display the currently working processes.top: Display all running processes.kill pid: Kill the process with the given PID.killall proc: Kill all processes named proc.pkill pattern: Kill all processes matching the pattern.bg: List stopped or background jobs, resume a stopped job in the background.fg: Bring the most recent job to the foreground.fg n: Bring job n to the foreground.File Permission ManagementChange File Permissionschmod octal file: Change the permission of the file to octal.r (read) = 4w (write) = 2x (execute) = 1sh chmod 777 filenameSearchinggrep pattern file: Search for the pattern in the file.grep -r pattern dir: Search recursively for the pattern in the directory.locate file: Find all instances of the file.find . -name filename: Search in the current directory and below it for files and directories with names starting with filename.pgrep pattern: Search for all the named processes that match the pattern.System Informationdate: Show the current date and time.cal: Show this month's calendar.uptime: Show current uptime.w: Display who is online.whoami: Display the current user.finger user: Display information about the user.uname -a: Show kernel information.cat /proc/cpuinfo: Show CPU information.cat /proc/meminfo: Show memory information.man command: Show the manual for the command.df: Show disk usage.du: Show directory space usage.free: Show memory and swap usage.whereis app: Show possible locations of the application.which app: Show which application will be run by default.Compressiontar cf file.tar file: Create tar named file.tar containing file.tar xf file.tar: Extract the files from file.tar.tar czf file.tar.gz files: Create a tar with Gzip compression.tar xzf file.tar.gz: Extract a tar using Gzip.tar cjf file.tar.bz2: Create tar with Bzip2 compression.tar xjf file.tar.bz2: Extract a tar using Bzip2.gzip file: Compress the file and rename it to file.gz.gzip -d file.gz: Decompress the file.gz back to file.NetworkingNetwork Commandsping host: Ping host and output results.whois domain: Get whois information for domains.dig domain: Get DNS information for the domain.dig -x host: Reverse lookup host.wget file: Download file.wget -c file: Continue a stopped download.ShortcutsCommand Shortcutsctrl+c: Halts the current command.ctrl+z: Stops the current command, resume with fg in the foreground or bg in the background.ctrl+d: Logout of the current session.ctrl+w: Erases one word in the current line.ctrl+u: Erases the whole line.ctrl+r: Bring up a recent command.!!: Repeat the last command.exit: Logout of the current session.Grep and File Count Examplesshgrep "this" demo_fileshgrep -r "ramesh" *shgrep -l "this" demo_*To count all lines:shwc -l fileTo filter and count only lines with a pattern:shgrep -w "pattern" -c fileFile PermissionsView and Change Permissionsls -ltr: View permissions of files/folders.chmod 777 filename: Change access permissions of files.Command HistoryCheck Command HistoryshhistoryAdditional ExamplesCreate a file:shtouch fruits.txtView file content:shcat fruits.txtshvi devops.txtAdd the following content:mathematicaAppleMangoBananaCherryKiwiOrangeGuavaSave and quit:Press i to insert content.Press Esc, then type :wq and press Enter.Top three lines:shhead -3 filenameBottom three lines:shtail -3 filenameshdiff file1 file24oxList Directory ContentsChange DirectoriesFile Viewing and EditingFile and Directory ManagementDisplay ProcessesKilling ProcessesJob ControlExample:Search PatternsLocate and FindSearch ProcessDisplay System InfoDisk and Memory UsageLocate ApplicationsTar ArchivesGzip CompressionSearch for a String in a Single FileSearch Recursively in All FilesDisplay Only Matching File NamesCount Lines in a FileCreate and View File ContentAdd Content to FileDisplay Specific LinesFind Differences Between FilesBy mastering these Unix/Linux commands, you can efficiently manage files, processes, and system resources, enhancing your productivity and system administration skills. Comments
Comments
Post a Comment