UNIX Command Cheat Sheets - Del Mar College

2y ago
29 Views
5 Downloads
648.68 KB
11 Pages
Last View : 1m ago
Last Download : 2m ago
Upload by : Cade Thielen
Transcription

UNIX Command Cheat SheetsUNIX Command Cheat SheetsCommandDescription (short)ExampleExplanationdateWrites the current date to the screendateMon Nov 20 18:25:37 EST 2000sort infileSorts the contents of the input file inalphabetical ordersort namesSorts the contents of names inalphabetical orderwhoTells you who is logged onto your serverwhoNonewho am ITells you your user informationwho am iwhoamiNoneclearClears the window and the line bufferclearNoneecho whatever I typeWrites whatever I type to the screen.echo hey you!Writes hey you! to the screenbanner big wordsDoes the same thing as echo only in BIGwordsbanner hey!Writes hey! in large letters on thescreencat file1 file2 file3Shows the three files in consecutive order asone document (can be used to combine files)cat cheese milkThis prints the cheese file to thescreen first and immediately followsit with the milk file.df systemReports the number of free disk blocksdf df HOMEBoth commands will print the total kbspace, kb used, kb available, and%used on the home system (yoursystem).head filePrints the first 10 lines of the file to the screenhead addressesNumber of lines can be modifiedhead -25 addressesPrints the first 10 lines of addressesto the screenPrints the first 25 lines of addressesto the screenPrints the last 10 lines of the file to the screentail test.txtNumber of lines can be modified here, tootail -32 test.txtThis prints to screen whatever is input—usefulbecause it only shows one screen at a time.scroll bar continues to the next screenreturn moves one line forwardQ quitsG goes to the end1G goes to the beginningCtrl u moves up ½ screenCtrl d moves down ½ screenmore groceriestail filemore inputPrints the last 10 lines of test.txt tothe screenPrints the last 32 lines of test.txt tothe screenThis will list the groceries file to thescreen.Page 1Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

Commandls (-option-optional)Description (short)Lists all the nonhidden files and directoriesExamplelsls binls -lorllls -aLists all nonhidden files and directories in longformatLists all files and directories including hiddenonesls -lllls -l workll workls -als -a templs -rLists all files and directories in reversealphabetical orderls -rls -r abcls -tLists all nonhidden files in the order they werelast modifiedls -tls -t workNOTE: Options can be combined using lsImportantCharacters & Wildcards“pipe” directs the output of the firstcommand to the input of another.Sends the output of a command to adesignated fileAppends the output of a command to adesignated fileRuns command in the background; you canstill work in the windowDesignates the home directory ( HOME)Designates input from somewhere other thanterminalls -alls -l morels -l myfilesls -l allfilesxclock &echo Lists your files in long format one screenat a timePrints your listing to a file named myfilesAppends your filenames to the end of theallfiles fileRuns xclock (a clock) allowing you tokeep workingWrites your home directory to the screenprogA program gets its input from a filenamed input1progA input1UNIX has a set of wildcards that it accepts.*Any string of charactersls *.c?Any one characterls file?Match any character in the brackets (a hyphen isused for ranges of characters)ls v[6-9]file[ ]ExplanationLists all nonhidden files and directories inthe current directoryLists all nonhidden files and directories inthe bin directoryLists all nonhidden files and directories inthe current directory in long formatLists all nonhidden files and directories inthe work directory in long formatLists all files and directories, includinghidden, in the current directoryLists all files and directories in the tempdirectory.Lists all nonhidden files and directories inthe current directory in reversealphabetical orderLists all nonhidden files and directories inthe abc directory in reverse alphabeticalorderLists all the nonhidden files in the currentdirectory in the order they were lastmodified from most recent to lastLists all the nonhidden files in the workdirectory in the order they were lastmodified from most recent to lastLists all files (including hidden (-a)) inlong format (-l)Lists any file or directory (nonhidden)ending with cLists any file/directory with file and 1character at the endLists v6file, v7file, v8file, and v9filePage 2Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

Commandcd directoryDescription (short)ExampleChanges your current directory to the directoryspecifiedcd bincd .cd ./.cd cd cdmkdir dirnameCreates a directorymkdir junkYou can also designate where the directory is to reside.mkdir /leftrm file1 file2 file3Removes (deletes) file(s)rm -i file1 file2Prompts before deletion of files*******USE -i AT FIRST*******rm xyzrm xyz abcrm *rm -i *rm -f file1 file2Forces deletion without prompt regardless ofpermissionsRemove a directory along with anything inside of itrm -r directoryrm -R directoryrmdir directory****dangerous****rm -fR namerm -Rf namerm -Ri directoryRemoves a directory like rm -r does if the directory isemptyThis combination will force the removal of any fileand any directory including anything inside of itDeletes the contents of a directory and the directory ifit is empty by prompting the user before each deletionrm -f programrm -r binrm -R binrmdir binrm -Rf c yarm -Ri rusureExplanationChanges directory to the bindirectoryMoves you to the directory thatcontains the directory you are currentlyinEx. Currentdirectory /home/users/bob/binexecute cd .New directory /home/users/bobor executing cd ./.New directory /home/users.Moves you to the directory you justcame fromBoth move you to your homedirectory (the directory you start frominitially)Makes a directory named junk inyour current directoryMakes a directory in your homedirectory named leftDeletes a file named xyzDeletes the files named xyz and abcDeletes everything nonhiddenPrompts at each nonhidden file andlets you decide whether or not todelete itRemoves the file program withoutregard to permissions, status, etc.Each of these will remove the bindirectory and everything inside of it.Removes the bin directory if it isemptyForces removal without prompts ofthe c ya directory and anythinginside of itDeletes anything in the directorycalled rusure that you verify at theprompt, and if you remove everythingin the directory, you will be promptedwhether you want to remove thedirectory itself or notNOTE: Options can be combined using rmrmdir -p directoryRemoves a directory and any empty parentdirectories above it (-pi does the same thing butit prompts before each removal)rmdir -p /home/bin/dir1Deletes the dir1 directory; if bindirectory is empty, it is deleted, and ifhome directory is empty it is alsodeletedPage 3Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

Commandcp file1 newnameDescription (short)Copies a file (file1) and names thecopy the new name (newname)Examplecp old newcp file dir2/cp ./dir1/* .cp -p name targetPreserves all permissions in theoriginal to the targetcp -p execut1 execut2cp -R directory targetCopies a directory and names thecopy the new name (target)Forces existing pathnames to bedestroyed before copying the fileRenames files and directoriescp -R old/ junk/cp -f name targetmv initial finalnonemv temp script 1ExplanationMakes a copy of the file/directorynamed old and names the copy new,all within the current directoryNOTE: If you copy a file to a newfilename and newfile already exists, thenewfile contents will be overwritten.Places a copy of file in dir2/ and itretains its original nameCopies everything from the dir1directory located just below where youcurrently are and places the copy“here” ( . ) in your current directoryCopies execut1 executable file andcalls the copy execut2, which also hasexecutable permissionsMakes a copy of the directory namedold and names the directory copy junkNo example or description neededRenames the file (or directory) temp tothe name script 1 in the currentdirectoryMoves the script.exe file to the bindirectory that is in the home ( ) parentdirectory and it keeps its initial nameMoves both script 1 and script.exe tothe bin directoryAlso moves files to otherdirectoriesmv script.exe /binYou can do multiple moves.mv script 1 script.exe /binpwdPrints the current directory to thescreenpwdMay print something like “/home/bob”pr (option) filenamepr userlistPrints the contents of userlist to thedefault printerpr k filenamePrints the specified file to thedefault printer (options are notrequired but can be combined inany order)Starts printing with page kpr 5 userlistpr -k filenamePrints in k columnspr -2 userlistpr -a filenamePrints in multicolumns across thepage (use with -k)Prints in double space formatpr -3a userlist1Prints the contents of userlist startingwith page 5Prints the contents of userlist in 2columnsPrints userlist in three columns acrossthe pagePrints userlist with double spaceformatpr -d filenamepr -h “header” filenamePrints the file with a specifiedheader rather than the filenameNOTE: Options can be combined using prpr -d userlistpr -h “users” userlistPrints userlist with users as theheaderPage 4Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

CommandDescription (short)lpconfig printer id queueConfigures remote printers to alocal print queueExamplelpconfig prntr1 bobprtlpconfig -r queueRemoves the said queue from the localsystemlpconfig -r bobprtlpconfig -d queueMakes the said queue the default queuelpconfig -d vpprntlpstat (-options)Prints printer status information to screen(options not required)lpstatlpstat -u“user1, user2”Prints the status of requests made by thespecified usersPrints the queues and the printers they printtoShows all print status informationShows the default printer for the lpcommandLets you know if the line printer scheduleris runningLike pr, this prints designated files on theconnected printer(s) (options not requiredand options may be combined).Prints the file(s) to a specific destinationlpstat -u“bob”lpstat slpstat -tlpstat -dlpstat -rlp (-option) file(s)lp -ddest file(s)lp -nnumber file(s)lp -ttitle file(s)lp -ooption file(s)ExplanationConfigures a printer named prntr1to accept print requests from a localqueue named bobprtRemoves bobprt queue from thelocal system if the person removingthe queue is the owner or “root”Makes vpprnt the default print queuenonePrints status of all requests made tothe default printer by the currentserverPrints status of all requests made bythe user with the id bobNonenonenoneNoneNonenoneNonelp junkfilePrints the file junkfile to the defaultprinter in default one-sided, singlesided, single-spaced formatSends the file zoom to the bobsq printqueue to printPrints five copies of crash in defaultsettingsPrints Bobs on the banner page of thefile printout named cashPrints the output file double-sided onthe printoutlp -dbobsq zoomAllows user to designate the number ofcopies to be printedPlaces title on the banner pagelp -n5 crashAllows printer-specific options to be used(i.e., double-sided or two pages per side,etc.)lp -od outputlp -tBobs cashlp -obold outputlp -ohalf outputlp -oquarter outputlp -olandscape outputlp -oportrait outputPrints output in bold printDivides the paper into two halves forprinting outputPrints four pages of output per sideof paperPrints output in landscape orientationPrints output in portrait orientationNOTE: Options can be combined using lpcancel request idcancel -a printercancel -u login idStops print jobs or removes them from thequeue (request ids are obtained usinglpstat)Removes all print requests from the currentuser on the specified printerRemoves any print requests queuedbelonging to the usercancel 5438cancel -a bobsprtcancel -u bobStops the print job with the id 5438whether it is printing or if it is sittingin the queueRemoves all the requests from thecurrent user to the printer namedbobsprtCancels all queued print requests foruser bobPage 5Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

CommandpsDescription (short)ExampleExplanationShows certain information about activeprocesses associated with the currentterminalShows information about all processespsps -fShows a full listing of information aboutthe processes listedps -fps -u user idps -u bobps -efShows all processes that are owned by theperson with the pertinent user idShows all processes in a full listingps -efkill process idkill -9 process idStops the process with the said idDestroys the process with the said idkill 6969kill -9 6969Kills the process with PID 6969PID # 6969 doesn’t have a chancehere.grep string fileSearches input file(s) for specified stringand prints the line with matchesgrep mike lettergrep -c string fileSearches and prints only the number ofmatches to the screengrep -c hayes banklettergrep -i string fileSearches without regard to letter casegrep -i hi file1grep -n string filePrints to the screen preceded by the linenumbergrep -n abc alphagrep -v string fileAll lines that do not match are printedgrep -v lead pencilsgrep -x string fileOnly exact matches are printedgrep -x time meetingsgrep is useful when you use it in a “pipe”ps -ef grep bobSearches for the string mike in the filenamed letter and prints any line withmike in it to the screenSearches the file bankletter for thestring hayes and prints the number ofmatches to the screenSearches file1 for hi, Hi, hI, and HIand prints all matches to the screenSearches alpha for abc and prints thematches’ lines and line numbers to thescreenPrints all lines in pencils that do notcontain the string leadPrints only lines in meetings thatmatch time exactlyFinds all processes in full listing andthen prints only the ones that match thestring bob to the screenSearches the file b days for caseinsensitive matches to jan and placesthe matching lines into a file calledmymonthps -eYou can also redirect its output to afile.ps -egrep -i jan b days mymonthShows a listing of process IDs,terminal identifier, cumulativeexecution time, and command nameShows a listing of process IDs,terminal identifiers, cumulativeexecution time, and command namesfor all processesShows UID (user or owner of theprocess), PID (process ID--use thisnumber to kill it), PPID (process ID ofthe parent source), C (processorutilization for scheduling), STIME(start time of the process), TTY(controlling terminal for the process),TIME (cumulative time the processhas run), and COMMAND (thecommand that started the process)Shows all the processes that belong tothe person with the userid bobShows all current processes in fulllistingPage 6Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

CommandDescription (short)ExampleExplanationvuepad filenameOpens filename for editing/viewing in the vuepadeditornoneNonevi filenameText editor that exists on every UNIX system inthe worldnoneNoneemacs filenameAnother text editornoneNonecompress filenameuncompress filenameCompresses the file to save disk space.Expands a compressed filenonenoneNoneNoneawkUNIX programming languagenoneNoneeval resize Tells the target computer that you’ve resized thewindow during telnetnoneNonechexp # filenameKeeps the file(s) from expiring (being erased) onthe target computer for # dayschexp 365 nr*Keeps the target computer fromdeleting all files starting with nrfor 1 year (365 days)Makes all files whose namestarts with nr never expire or bedeleted (infinite)chexp 4095 nr*qstatDisplays the status of a process that has beensubmitted the Network Queuing System (basicallya batch job)qstatqstat -aqstat -lqstat -mqstat -u bobqstat -xxtermxterm -optionxterm optionxterm -helpOpens a new window (x-terminal) for you to work-option sets the option option resets the option to defaultDisplays the xterm optionsxtermxterm -helpShows the status of the requestssubmitted by the invoker of thecommand—this will printrequest-name, request-id, theowner, relative request priority,and request state (is it runningyet?)Shows all requestsShows requests in long formatShows requests in mediumlength formatShows only requests belongingto the user bobQueue header is shown in anextended formatThis opens another window likethe one you are currentlyworking in.USING XTERM WILLELIMINATE A LOT OFDESKTOP CLUTTER. ISTRONGLY SUGGESTYOU LEARN TO USE ITIN YOUR SCRIPTS.Shows the options availablePage 7Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

Commandxterm -e programxterm -sbxterm -sl numberxterm -geom xxy px pyDescription (short)ExampleExecutes the listed program in thenew xterm window—when theprogram is finished, the new xtermwindow goes awayOpens an xterm that saves a setnumber of lines when they go off thetop of the page and makes themaccessible with a scroll barxterm -e myprog.exeSpecifies the number of lines to besaved once they go off the top of thescreen (default is 64)xterm -sl 1000This option allows you tospecify the size x pixels by ypixels and placement positionx by position y of the newwindow when it opens.Position 0 0 is the top lefthand corner of the screen, andthe bottom right is approx. 1200 1000 depending onyour resolution.Note: The size of the windowtakes precedence over position,so if you position it too close tothe side of the screen, it willposition at the edge with thecorrect size.xterm -sbxterm -geom 80x80 0 50xterm -geom 10x35 300 500xterm -geom 5x5 0 0xterm -title labelAllows you to label your window’stop title barxterm -title SCRIPTS(Explanation)This opens an xterm window andexecutes the program myprog.exefrom that window so that you maystill work in your present window.Puts a scroll bar on the right side ofthe page for reviewing past lines inthe windowNOTE: When clicking in the scrollbar, the left button scrolls down, theright scrolls up, and the middlesnaps the scroll bar to the mouseposition for dragging up and down.The xterm will save 1,000 lines ofwork once it has moved off theimmediate viewing area; it can beaccessed using the scroll bar.The first command will open awindow 80 pixels wide by 80 pixelstall and position its top left-handcorner at 0 pixels to the right of theleft edge and 50 pixels down fromthe top of the screen.The second command will open awindow 10 pixs wide by 35 pixs talland position its top left-hand corner300 pixs from the left edge and 500pixs down from the top.The third command will make a 5 by5 window and position its top lefthand corner at the top left-handcorner of the screen.xterm will not compromise sizewhen positioning.Opens an xterm window with thetitle SCRIPTS (default is whateverfollows the -e option)Page 8Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

xterm -(areas) colorAllows you to modify different colorsin your xterm windowxterm -bg whitexterm -bd huntergreenxterm -fg redxterm -fn fontSets the font in the new xtermwindowxterm -iconicStarts the new xterm as an icon(double-click to maximize)NOTE: Options can be combined using xtermxterm -fn courr18xterm -iconic -title xyzThe first command sets thebackground color to white.The second command sets thewindow border color tohuntergreen.The third command window sets thetext color to red.Sets the font to courr18 (default isfixed)Opens an xterm in iconic form withthe title xyzPage 9Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

Related TechRepublic resources:UNIX Command Cheat SheetsTechRepublic books and CDs:IT Security Survival GuideIT Professional's Guide to Policies and Procedures, Third EditionQuick Reference: Server Commands PakCisco Router Administration Smart PakAdministrator's Guide to Active Directory, Second EditionDownloads:50 essential Excel tipsIndispensable tips for Word usersVirus basics PowerPoint presentationSockets networking chapter from UNIX Network Programming: The Sockets Networking API, Vol.1, Third EditionArticles and columns:Tech Tip: Use awk to format outputTech Tip: Update RPMs with urpmiSANS/FBI releases latest top 10 Linux/UNIX vulnerabilitiesRun Windows applications on Linux with WINEPage 10Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

TechRepublic:The collective voice of IT professionalsTechRepublic communities engage IT professionals in the ultimate peer-to-peer experience, providingactionable information, tools, and services to help members get their jobs done. TechRepublic serves theneeds of the professionals representing all segments of the IT industry, offering information and tools forIT decision support and professional advice by job function.CIO Republic: Get analysis and insight on e-business, leadership, executive careers, business strategy,and technology.IT Manager Republic: Access technology insights, project and personnel management tips, and trainingresources.NetAdmin Republic: Get tips on Windows, NetWare and Linux/UNIX administration, infrastructuredesign, and network security.Support Republic: Obtain detailed solutions to desktop hardware, software, and end-user supportproblems.IT Consultant Republic: Find information and advice on client and vendor relations, projectmanagement, and technology.TechRepublic site featuresFree e-newsletters: Keep up-to-date on any aspect of the IT industry with e-newsletters—from techstocks to daily software tips, from IT careers to hot trends—delivered right to your e-mail Inbox.Free downloads: We've collected resources to make your job easier, including ready-to-use IT formsand templates, checklists, tools, executables, Gartner product analyses, and white papers.TechRepublic's books and CDs: Find the latest books and CDs about today's critical IT topics, includingPC troubleshooting, VPN, TCP/IP, Windows client and server issues, and Cisco administration.Discussion center: Open a discussion thread on any article or column or jump into preselected topics:career, technology, management, and miscellaneous. The fully searchable Discussion Center brings youthe hottest discussions and threads and allows you to sort them by topic and by republic.Try our premium subscription product, TechProGuild, free for 30 days. Our online IT communityprovides real-world solutions and the latest articles, resources, and discussions affecting frontline IT pros.Get access to more than 250 full-text IT books, along with exclusive downloads and in-depth articles onnetwork and system administration, PC troubleshooting, help desk and support issues, and more.Page 11Copyright 2004 CNET Networks, Inc. All rights reserved.To see more downloads and get your free TechRepublic membership, please visithttp://techrepublic.com.com/2001-6240-0.html.

UNIX Command Cheat Sheets UNIX Command Cheat Sheets Command Description (short) Example Explanation date Writes the current date to the screen date Mon Nov 20 18:25:37 EST 2000 sort infile Sorts the contents of the input file in alphabetical order sort names Sorts the contents of names in alphabetical order

Related Documents:

Cissp cheat sheet all domains. Cissp cheat sheet 2022 pdf. Cissp cheat sheet 2022. Cissp cheat sheet domain 4. Cissp cheat sheet pdf. Cissp cheat sheet 2021. Cissp cheat sheet domain 1. Cissp cheat sheet reddit. We use cookies to offer you a better browsing experience, analyze site traffic, personalize content, and serve targeted advertisements.

Google Slides Cheat Sheet p. 15-18 Google Sheets Cheat Sheet p. 19-22 Google Drawings Cheat Sheet p. 23-26 Google Drive for iOS Cheat Sheet p. 27-29 Google Chrome Cheat Sheet p. 30-32 ShakeUpLearning.com Google Cheat Sheets - By Kasey Bell 3

This is a standard UNIX command interview question asked by everybody and I guess everybody knows its answer as well. By using nslookup command in UNIX, you can read more about Convert IP Address to hostname in Unix here. I hope this UNIX command interview questions and answers would be useful for quick glance before going for any UNIX or Java job interview.

Unix 101: Introduction to UNIX (i.e. Unix for Windows Users) Mark Kegel September 7, 2005 1 Introduction to UNIX (i.e. Unix for Windows Users) The cold hard truth · this course is NOT sponsored by the CS dept. · you will not receive any credit at all introduce ourselv

Git-cheat-sheet Optional Reading: Bourbon-cheat-sheet CLI-cheat-sheet Git-for-subversion-cheat-sheet Tower-cheat-sheet (for Mac or Windows depending on your computer) Website_optimization-cheat-sheet Workflow-of-version-control Xcode-cheat-sheet _tower-git-client (

Command Library - String Operation Command Command Library - XML Command Command Library - Terminal Emulator Command (Per Customer Interest) Command Library - PDF Integration Command Command Library - FTP Command (Per Customer Interest) Command Library - PGP Command Command Library - Object Cloning

UNIX and POSIX APIs: The POSIX APIs, The UNIX and POSIX Development Environment, API Common Characteristics. UNIT – 2 6 Hours UNIX Files: File Types, The UNIX and POSIX File System, The UNIX and POSIX File Attributes, Inodes in UNIX

Article by Barbara Ehrenreich and Arlie Russell Hochschild, Introduction, Global Women: Nannies, Maids, and Sex Workers in the New Economy, edited by Barbara Ehrenreich and Arlie Russell Hochschild. New York: Henry Holt, 2002, pp. 1–10. Source: Introduction of the book Global Woman: Nannies, Maids, and Sex Workers in the New Economy