Linux Commands
Linux commands
- The command line - Terminal, Xterm, or similar
- Commads are similar in both Linux and masOS - macOS derived from BSD (Berkeley software Distribution) Unix, (macOS is derived from Unix Linux)
- Download a Live CD or install a virtual machine - Many pre-made Linux distributions are available
- Use the 'man' command for help - An online manual > 'man grep'
ls
List directory
- List directory contents - Similar to the 'dir' command in Windows
- Lists files, directories - May support color coding, Blue is a directory, red is an archieve files, etc
- For long output pipe through more - '> ls -l | more' (use 'q' or 'Ctrl-c' to exit)
- ('| more': to present the output one page at a time)
pwd
- Print Working Directory - Displays the current working directory path, Useful when changing directions often
Windows - cd
mv
- Move a file - Rename a file
- 'mv source dest' - ex) mv first.txt second.txt
- -> remain only second.txt
cp
- Copy a file - Duplicate files or directories
- 'cp source dest' - ex) cp first.txt second.txt
- -> remain both, first.txt and second.txt
rm
- Remove files or directories - Deletes the files
- Does not remove directories by default - Directories must be empty to be removed or must be removed with '-r'
chmod
- Change mode of a file system object
- r = read (4), w = write (2), x = execute (1)
- Can also use octal notation
- Set for the file owner(u), the group(g), other(o), or all(a)
- 'chmod mode FILE' - ex) chmod 744 script.ssh
- ex) drwx------ => directory user: 7, group: 0, others: 0 | -rwxr--r-- => user: 7, group: 4, others: 4
- ex) 'chmod a-w first.txt' : all users, no writing to first.txt
- ex) 'chmod u+x script.ssh : The owner of script.ssh can execute the file
chown
- Change file owner and group - Modify the settings
- 'sudo chown [OWNER:GROUP] file' > ex) 'sudo chown professor first.txt'
- 'sudo' requires additional rights and permissions
su / sudo
- Some command require elevated rights - There are some things normal users can't do
- 'sudo' - Execute a command as the superuser, OR as a different user ID, The specified command executes as the super user
- 'su' - Become super user, Or change to a different user, You continue to be that user until you 'exit'
apt-get
install/uninstall
- Advanced Packaging Tool - Handles the management of application packages, Applications and utilities
- Install, update, remove - ex) 'sudo apt-get install wireshark'
yum
When you can't use 'apt-get' based on one of the Red Hat versions of Linux
- Yellowdog updater, Modified (yum) - Install, delete, update
- Manage RPM packages - Red Hat Package Manager, RPM Package Manager
- A Linux distribution will commonly use either 'yum' or 'apt-get'
ip
- Manage the network interfaces - Enable, disable, configure addresses, manage routes, ARP cache, etc
- ip address - View interface addresses
- ip route - View the IP routing table
- 'sudo ip address add ip address/subnet mask dev the name of the adapter'
- ex) 'sudo ip address add 192.168.121.241/24 dev eth0', Configure the IP address of an interface
dev: device
df
- Disk free - View file systems and free space
- 'df' - View number of blocks -> may not be very intuitive
- 'df -h' - View human-readable sizes -> much understandable
grep
- Find text in a file - Search through many files at a time
- 'grep PATTERN [FILE]' - ex) grep failed auth.log
ps
- View the current proccesses - And the process ID (PID), Similar to the Windows Task Manager
- View user processes - 'ps' -> just the processes running for yourself or your user name
- View all processes - 'ps -e | more'
top
- View CPU, RAM, and resource utilizations - The 'Task Manager' for Linux
- Process information - Easy to find the highly utilized applications
- Summary of overall load - One, five, fifteen minutes
- Many different options - Check the man page for startup options and keys
find
- Find a file by name or extension - Search through any or all directories
- Find files with a specific extension - ex) 'file . -name "*.txt"'
- . : where you'd like to begin the search | period(your current folder)
- * : all of the file
- "*.txt" : specify the name of the file you're looking for
dig
- Lookup information from DNS servers - Canonical names, IP addresses, cache timers, etc
- 'dig' (Domain Information Groper) - Detailed domain information, Add 'dig' to Windows
Windows: nslookup
cat
- Concatenate - Link together in a series
- Copy a file/files to the screen - ex) 'cat file1.txt file2.txt'
- Copy a file/files to another file - ex) 'cat file1.txt file2.txt > both.txt'
- -> group a file or files to one file (everything contents is one file)
nano
- Full-screen text editor - Easy to edit
- Included with many Linux distributions - Easy to install
- Select, mark, copy/cut, and paste text - Similar features to graphical-based editors
- Ctrl+O : save
Linux Feature
Backups
- Many options - Command line and graphical, May be included with the distribution
- 'tar' - Tape Archive, Easy to script into a backup schedule - zip
- 'rsync' - Sync files between storage devices, Instant synchronization or scheduled
- Command line tools - 'apt-get', 'yum'
- Graphical update managers - Software updater
- Patch management - Updates can be scheduled
- Software center - The Linux "App store"
tar [options] [archive-fike] [file or directory to be archived]
- [options] : Optional flags or settings that modify the behaviour of the tar command.
- [archive-file] : The name of the archive file you are creating or working with.
- [file or directory to be archived] : The file or directory you want to include in the archive.
Anti-virus / Anti-malware
- Relatively few viruses and malware for Linux (masOS as well) - Still important to keep updated
- Clam Antivirus (ClamAV) - Open source antivirus engine
- Some best practice as any other OS - Always update signature database, Always use real-time scanning
Shell / Terminal
- Command line across to the OS - Common to manage in Linux
- OS maintenance - Run script, manage files, Configure OS and application settings
- (Linux user or administering a Linux)
Samba
- Add SMB (Server Message Block) to Linux - File and print sharing (to Windows), Active Directory integration
- Integrate Linux tnto a Windows environmnet - Linux becomes a Windows file server
SMB: a protocol used by Windows to transfer files, access network shares, or print to a network printer
'CompTIA A+ > 220-1102' 카테고리의 다른 글
1.10 macOS (0) | 2024.02.22 |
---|---|
1.9 Installing Operating Systems (0) | 2024.02.17 |
1.8 Operating System Types (0) | 2024.02.16 |
1.7 Installing Applications (0) | 2024.02.16 |
1.6 Windows Networking (0) | 2024.02.16 |