The 101 Most Important UNIX and Linux Commands
()
About this ebook
This book delivers what the title states: It describes the 101 most important UNIX and Linux commands and system calls. The book bridges the gap between on-line tutorials and manual pages on one hand, and books of 1,000 pages or more that explore the nuances of many shell commands in exhaustive detail. While most of these sources provide excellent information, they do not really solve the plight of the novice user, nor do they fully answer the questions that more experienced, and even expert, users often have. Much of the complexity of UNIX and Linux, and much of the difficulty faced by users is caused by the extremely large and rich set of shell commands, many of which have a very large set of allowable options that, while useful in certain circumstances, often provide more frustration than help because of their complexity. Many UNIX and Linux system calls are also complex, and have interactions that can be rather difficult for many programmers.
The many variants of UNIX cause additional difficulties. Even Linux has multiple variants: there are often subtle differences in the Linux implementations by Red Hat (Fedora), Ubuntu, SUSE, and Debian. For example, one of my recent senior students had a major project that required using a particular "Linux" software application containing a particular language's character set and grammar. The software would not work (indeed, it would not even install properly) on three of the most common Linux implementations!
Our approach is to focus on a smaller set of commands and system calls – the ones that are most important. For each of these, only the most useful of the many options are described.
As a professor, I taught operating systems in general, and UNIX in particular, for over twenty-five years. As the author of the book Advanced Topics in UNIX, which was selected as a main selection on UNIX by the Newbridge Book Club, and Advanced Topics in UNIX, Second Edition (available electronically on this ebook platform), I had to make choices in what I presented and how I presented it. Finally, as an analyst/consultant on many different applications in multiple UNIX and Linux systems, I had to make choices based on the quality of the source code, and on its performance and maintainability.
I am confident that I have made the correct choices in selecting which of the many shell commands, system calls and options to discuss in this book and at what level they should be discussed. I hope you agree.
Ronald J. Leach
About the Author I recently retired from being a professor of computer science at Howard University for over 25 years, with 9 of those years as a department chair. (I was a math professor for 16 years before that.) While I was department chair, we sent more students to work at Microsoft in the 2004-5 academic year than any other college or university in the United States. We also established a graduate certificate program in computer security, which became the largest certificate program at the university. I had major responsibility for working with technical personnel to keep our department’s hundreds of computers functional and virus-free, while providing email service to several hundred users. We had to withstand constant hacker attacks and we learned how to reduce the vulnerability of our computer systems. As a scholar/researcher, I studied complex computer systems and their behavior when attacked or faced with heavy, unexpected loads. I wrote five books on computing, from particular programming languages, to the internal structure of sophisticated operating systems, to the development and efficient creation of highly complex applications. My long-term experience with computers (I had my first computer programming course in 1964) has helped me understand the nature of many of the computer attacks by potential identity thieves and, I hope, be able to explain them and how to defend against them, to a general audience of non-specialists. More than 5,000 people have attended my lectures on identity theft; many others have seen them on closed-circuit television. I have written more than twenty books, and more than 120 technical articles, most of which are in technical areas. My interests in data storage and access meshed well with my genealogical interests when I wrote the Genealogy Technology column of the Maryland Genealogical Society Journal for several years. I was the editor or co-editor of that society’s journal for many years.
Read more from Ronald J. Leach
Confessions of a Cruise Lecturer Rating: 0 out of 5 stars0 ratingsData Recovery Rating: 0 out of 5 stars0 ratingsDigitizing Microfilm and Microfiche Rating: 0 out of 5 stars0 ratingsRecovering From Identity Theft Rating: 0 out of 5 stars0 ratingsSoftware Reuse: Methods, Models, Costs, Second Edition Rating: 0 out of 5 stars0 ratingsBaltimore Blue and Freddie Gray Rating: 0 out of 5 stars0 ratingsThe Bible as a Manual for Identity Theft Rating: 0 out of 5 stars0 ratingsTwelve and a Half Steps to Avoid Identity Theft Rating: 0 out of 5 stars0 ratingsUser Guide to Microfilm and Microfiche Rating: 0 out of 5 stars0 ratingsWhy 2K? Rating: 0 out of 5 stars0 ratingsEat Kids at School Rating: 0 out of 5 stars0 ratingsWhere Have All The Templars Gone? Rating: 0 out of 5 stars0 ratings
Related to The 101 Most Important UNIX and Linux Commands
Related ebooks
Unix and Linux System Administration: Mastering the Command Line. A Comprehensive Guide to Unix and Linux System Administration Rating: 0 out of 5 stars0 ratingsLinux: A Comprehensive Guide to Linux Operating System and Command Line Rating: 0 out of 5 stars0 ratingsI am Linux : Being A Ultra Linux User Rating: 0 out of 5 stars0 ratingsUNIX Shell Scripting Interview Questions, Answers, and Explanations: UNIX Shell Certification Review Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5UNIX for OpenVMS Users Rating: 0 out of 5 stars0 ratingsSimply Linux: Basics Rating: 5 out of 5 stars5/5Easy Linux For Beginners Rating: 2 out of 5 stars2/5Shell Scripting: Expert Recipes for Linux, Bash, and more Rating: 0 out of 5 stars0 ratingsLinux for Beginners: Linux Command Line, Linux Programming and Linux Operating System Rating: 4 out of 5 stars4/5LINUX FOR BEGINNERS: Navigating the Linux Universe with Confidence and Ease (2024 Beginner Guide) Rating: 0 out of 5 stars0 ratingsLinux: A complete guide to Linux command line for beginners, and how to get started with the Linux operating system! Rating: 0 out of 5 stars0 ratingsLinux: A Beginner's Guide to Linux Operating System Rating: 0 out of 5 stars0 ratingsLPI Linux Certification Questions: LPI Linux Interview Questions, Answers, and Explanations Rating: 4 out of 5 stars4/5Tru64 UNIX Troubleshooting: Diagnosing and Correcting System Problems Rating: 0 out of 5 stars0 ratingsThe Linux Command Line Beginner's Guide Rating: 4 out of 5 stars4/5Unix / Linux FAQ: with Tips to Face Interviews Rating: 0 out of 5 stars0 ratingsWork with the Command-line: To Manage Files and Directories in Ubuntu Rating: 5 out of 5 stars5/5Unix And Linux System Administration Handbook: Mastering Networking, Security, Cloud, Performance, And Devops Rating: 0 out of 5 stars0 ratingsMastering Linux Administration: A Comprehensive Guide: The IT Collection Rating: 5 out of 5 stars5/5Linux 5 Day Introduction Course Rating: 0 out of 5 stars0 ratingsAlpha AXP Architecture Reference Manual Rating: 0 out of 5 stars0 ratingsLinux Essentials - A Beginner's Guide To Linux Operating System Rating: 3 out of 5 stars3/5Linux Commands By Example Rating: 5 out of 5 stars5/5Ubuntu Linux Toolbox: 1000+ Commands for Power Users Rating: 4 out of 5 stars4/5Linux Services Deployment Rating: 0 out of 5 stars0 ratings
Operating Systems For You
Windows 11 All-in-One For Dummies Rating: 5 out of 5 stars5/5Exploring Apple iPhone: iOS 15 Edition: The Illustrated, Practical Guide to Using your iPhone Rating: 0 out of 5 stars0 ratingsThe Darknet Superpack Rating: 0 out of 5 stars0 ratingsMacOS Ventura Essentials: Support, Troubleshooting & Maintenance Guide for Beginners and Seniors Rating: 0 out of 5 stars0 ratingsExcel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Hacking : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Ethical Hacking Rating: 5 out of 5 stars5/5Linux Bible Rating: 0 out of 5 stars0 ratingsRaspberry Pi for Secret Agents - Second Edition Rating: 3 out of 5 stars3/5Learn SQL Server Administration in a Month of Lunches Rating: 3 out of 5 stars3/5Exploring Windows 11: The Illustrated, Practical Guide to Using Microsoft Windows Rating: 0 out of 5 stars0 ratingsLinux Command-Line Tips & Tricks Rating: 0 out of 5 stars0 ratingsThe Windows Command Line Beginner's Guide: Second Edition Rating: 4 out of 5 stars4/5Mastering Windows PowerShell Scripting Rating: 4 out of 5 stars4/5Linux Command Line and Shell Scripting Bible Rating: 3 out of 5 stars3/5Hacking Essentials - The Beginner's Guide To Ethical Hacking And Penetration Testing Rating: 3 out of 5 stars3/5Make Your PC Stable and Fast: What Microsoft Forgot to Tell You Rating: 4 out of 5 stars4/5Learn Windows PowerShell in a Month of Lunches Rating: 0 out of 5 stars0 ratingsMastering macOS Programming Rating: 0 out of 5 stars0 ratingsOneNote: The Ultimate Guide on How to Use Microsoft OneNote for Getting Things Done Rating: 1 out of 5 stars1/5The Linux Command Line Beginner's Guide Rating: 4 out of 5 stars4/5Raspberry Pi Cookbook for Python Programmers Rating: 0 out of 5 stars0 ratingsMastering Linux Shell Scripting Rating: 4 out of 5 stars4/5Tor Darknet Bundle: Master the Art of Invisibility Rating: 0 out of 5 stars0 ratingsOperating Systems DeMYSTiFieD Rating: 0 out of 5 stars0 ratingsiPhone Unlocked Rating: 0 out of 5 stars0 ratingsNetworking for System Administrators: IT Mastery, #5 Rating: 5 out of 5 stars5/5Darknet Rating: 4 out of 5 stars4/5
Reviews for The 101 Most Important UNIX and Linux Commands
0 ratings0 reviews
Book preview
The 101 Most Important UNIX and Linux Commands - Ronald J. Leach
1. Introduction
Learning UNIX, including the most common variants (Linux, Apple Darwin, Mach, Solaris, BSD, FreeBSD, HP-UX, Xenix, AIX, AUX, etc.) is often a daunting task for both novice and relatively experienced users. The problem is the complexity of UNIX itself. To complicate matters, there are multiple Linux versions: Red Hat (now Fedora), Ubuntu, SUSE, and Debian are the most common. Linux itself was created by Linus Torvalds who, while a student at the University of Helsinki, was motivated to create a new kernel which would have the same functionality as UNIX and MINIX. (MINIX was created by Professor Andrew Tanenbaum of Vrije Universiteit in The Netherlands as a small modifiable version of UNIX that could be used for teaching purposes.) These UNIX versions have much more in common than they have differences, although the differences, when they occur, can be confusing even to an experienced user. As much as possible, we will focus on the commonality and discuss the major differences as appropriate.
Why is it so hard to understand UNIX? The UNIX operating system is entirely too large to be described in detail in any series of books, much less in a single book! Here’s an illustration of this point. Mark G. Sobell has written an excellent series of books on UNIX and Linux. Some titles in the series are:
A Practical Guide to Linux Commands, Editors, and Shell Programming ( 3rd Edition)- 1154 pages
A Practical Guide to Fedora and Red Hat Enterprise Linux, Sixth Edition- 1266 pages
A Practical Guide to Ubuntu Linux (3rd Edition)- 1251 pages
Clearly, there are sufficient differences between just these three variants to justify these large books devoted to a single variant. And these books only treat variants of Linux!
There are more than 2000 entries for common commands, system calls, and utilities in many on-line UNIX manuals. Unfortunately, using on-line manuals as the only source of information can be confusing and time-consuming. As an example, the associated on-line manual pages on one Solaris system implementation required 7234 megabytes for storage of the 2545 entries on disk. This is equivalent to more than 1400 pages of text! To make matters even more complicated, most system calls can have multiple arguments, many of which interact with other arguments, and the number and order in which these arguments occur can also vary. The combination of system calls with a typical number of arguments results in a syntax approximately as rich as the active vocabulary of the average high school graduate in the United States.
The spelling is also daunting to the new UNIX user. Why, for example, is there a system call named creat() instead of create()? Why is umount not spelled unmount? It makes no sense to anyone today, and may not have done so, even when these names were given. Of course, unusual spelling makes it even more difficult for anyone looking up these names in an on-line manual of commands.
Even after learning all this information in detail, you would be able to learn only the syntax and common error codes associated with these commands, system calls, and utilities. We’ll simplify matters here by limiting ourselves to what I judge to be the most important system calls and shell commands and for these, we will limit our discussion to the most important function arguments. My judgement of what is important is based on several things:
my experience as a professor teaching both novice and advanced students of UNIX over twenty times in classes on operating systems,
my experience as an author of two books on UNIX,
and my experience as a consultant who, while doing quality checks on software, analyzed many software systems running on UNIX and Linux operating systems and comprising hundreds of thousands of lines of code across several different application domains.
The system calls and shell commands that we will discuss here in this book are listed below. in alphabetical order. For clarity, we have indicated which ones are system calls by using parentheses. We have also grouped related commands on the same line.
Here is the alphabetical list:
accept()
awk
bind()
cat
cc
gcc
cd
chdir
chmod
chown
chroot
close()
connect()
cp
cpio
creat()
crontab
csplit,split
df
diff
du
dup
echo
edit, ed, sed, vi
exec
exec(), execlp(), execle(), execvp(), execve()
exit()
file
find
finger
for, foreach, do, done, if, ... (built-in shell commands)
fork()
ftp
getopt, getopt()
getuid(), geteuid(), getgid(), geteuid()
grep
head
man
IPC commands
ipcs
ipcstat
kill
listen()
ln
logout
lp
lpstat
ls
make
mkdir
mkfifo()
more
mount
msgctl()
msgget()
msgrcv()
msgsnd()
mv
newgrp
nice()
nmake
nslookup
open()
passwd
ping
pipe()
ps
pwd
rcmd
rcp
read()
restore
rlogin
rm
rmdir
RPC commands
rsh
semctl()
semget()
semop()
send()
set
setuid(), seteuid(), setgid(), setegid()
sh, csh, ksh, bash, posix shells
shmat()
shmctl()
shmdt()
shmget()
shutdown
signal()
sleep()
socket()
ssh
system()
tail
tar, ar, bar, rar, gzip, gunzip, zcat
telnet
thread commands
touch
umask
umount
uname
wait()
wc
who, whoami, whois
write()
Here is how the rest of this book is organized. In the rest of this introductory chapter there are two additional sections. One will provide an overview of UNIX and the other will describe the basics of UNIX system architecture.
Chapter 2 discusses the 101 most important UNIX shell commands and system calls. We provide the syntax of each of them, followed by a discussion of their design, usage and pitfalls, followed by examples of their most common usage.
There are two appendices. Appendix 1 is entitled The Most Essential UNIX Files.
In this appendix, we discuss the important files stdout, stdin, and stderr. We will also discuss file descriptors; the redirection commands <, <<, >, and >>; and how to use simple shell commands to do things such as redirect the contents of the errors in stderr to an error log file. Appendix 1 also contains a description of i-nodes and i-numbers to help explain some of the system calls, as well as a discussion of the differences between i-nodes in UNIX and Linux systems.
Appendix 2 is entitled The Most Essential C Functions
and includes a discussion of what I have found to be the most useful functions in the standard C library, plus a few useful functions from the math library. Functions such as memcpy(), which are not really system calls, are discussed here.
The book closes with a short list of relevant references.
1.1 Overview Of UNIX
UNIX is designed to be a powerful general purpose operating system that allows multiple users to use the computer at any one time and allows each of these users to be able to run many concurrent processes. It is currently implemented on a large variety of computers with different hardware architectures including: personal computers with a single processing core, personal computers with a multicore architecture, workstations, minicomputers, mainframes, supercomputers, and parallel computers. Many important software applications have versions that run on computers using some the UNIX operating system or some variant thereof.
The UNIX operating system was originally developed at AT&T Bell Laboratories by Dennis Ritchie and Ken Thompson. Their goal was to develop a small but powerful operating system that would be easily ported to computers other than the one for which the system was initially developed. UNIX had several important features.
• It had an elegant view of the features of an operating system in that every essential feature could be classified as either a file or a process.
• Files were streams of bytes, with any other structure of the file imposed by the application program accessing the file. No assumption about file organization such as database design, size of records, etc, was made by the operating system. Thus