
{"id":74,"date":"2025-06-04T21:36:53","date_gmt":"2025-06-04T20:36:53","guid":{"rendered":"https:\/\/blog.mkcloudai.com\/?p=74"},"modified":"2025-06-04T21:36:53","modified_gmt":"2025-06-04T20:36:53","slug":"daily-system-admin-commands","status":"publish","type":"post","link":"https:\/\/blog.mkcloudai.com\/?p=74","title":{"rendered":"Daily system admin commands"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">\ud83d\uddc2\ufe0f CATEGORIES:<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u2705 <strong>System Monitoring &amp; Info<\/strong><\/li>\n\n\n\n<li>\ud83d\udd10 <strong>Security &amp; Access<\/strong><\/li>\n\n\n\n<li>\ud83d\udcc1 <strong>Log Management<\/strong><\/li>\n\n\n\n<li>\ud83d\udce1 <strong>Network &amp; Firewall<\/strong><\/li>\n\n\n\n<li>\u2699\ufe0f <strong>Automation &amp; Backup<\/strong><\/li>\n\n\n\n<li>\ud83d\udce6 <strong>Package &amp; Service Management<\/strong><\/li>\n\n\n\n<li>\ud83e\udde0 <strong>Custom Scripts \/ Misc<\/strong><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u2705 1. SYSTEM MONITORING &amp; INFO<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>uptime<\/code><\/td><td>Shows how long the system has been running and load average.<\/td><\/tr><tr><td><code>who<\/code><\/td><td>Shows who is logged in.<\/td><\/tr><tr><td><code>w<\/code><\/td><td>Displays who is logged in and what they are doing.<\/td><\/tr><tr><td><code>top<\/code><\/td><td>Real-time view of CPU\/memory usage.<\/td><\/tr><tr><td><code>df -h<\/code><\/td><td>Shows disk usage in human-readable format.<\/td><\/tr><tr><td><code>free -m<\/code><\/td><td>Shows memory usage in MB.<\/td><\/tr><tr><td><code>hostname -I<\/code><\/td><td>Displays local IP address.<\/td><\/tr><tr><td><code>ps aux<\/code><\/td><td>Lists all running processes.<\/td><\/tr><tr><td><code>lsof<\/code><\/td><td>Lists open files, often used to trace processes using a file.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udd10 2. SECURITY &amp; ACCESS<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>last<\/code><\/td><td>Lists login history.<\/td><\/tr><tr><td><code>lastb<\/code><\/td><td>Lists failed login attempts (uses <code>\/var\/log\/btmp<\/code>).<\/td><\/tr><tr><td><code>whoami<\/code><\/td><td>Shows current logged-in user.<\/td><\/tr><tr><td><code>id<\/code><\/td><td>Shows user ID and groups.<\/td><\/tr><tr><td><code>sudo ufw status<\/code><\/td><td>Displays current UFW firewall rules.<\/td><\/tr><tr><td><code>sudo ufw allow 5000\/tcp<\/code><\/td><td>Allows incoming traffic on port 5000.<\/td><\/tr><tr><td><code>sudo ufw allow from YOUR.IP.ADDRESS to any port 5000<\/code><\/td><td>Allows only your IP to access port 5000.<\/td><\/tr><tr><td><code>sudo ufw deny from IP_ADDRESS<\/code><\/td><td>Blocks specific IP address.<\/td><\/tr><tr><td><code>sudo fail2ban-client status<\/code><\/td><td>Checks fail2ban status.<\/td><\/tr><tr><td><code>journalctl -u ssh<\/code><\/td><td>View logs for SSH service.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udcc1 3. LOG MANAGEMENT<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>cat \/var\/log\/auth.log<\/code><\/td><td>View authentication-related logs.<\/td><\/tr><tr><td><code>cat \/var\/log\/syslog<\/code><\/td><td>General system activity logs.<\/td><\/tr><tr><td><code>zcat \/var\/log\/syslog.1.gz<\/code><\/td><td>View compressed logs (rotated).<\/td><\/tr><tr><td><code>logrotate<\/code><\/td><td>Tool for automatic log rotation.<\/td><\/tr><tr><td><code>tar -czf logs-YYYY-MM-DD.tar.gz \/var\/log<\/code><\/td><td>Archive logs manually.<\/td><\/tr><tr><td><code>sha256sum logs-*.tar.gz<\/code><\/td><td>Create checksum to verify archive integrity.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udce1 4. NETWORK &amp; FIREWALL<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>curl http:\/\/127.0.0.1:5000\/<\/code><\/td><td>Test local Flask server access.<\/td><\/tr><tr><td><code>curl http:\/\/checkip.amazonaws.com<\/code><\/td><td>Get public IP address from AWS.<\/td><\/tr><tr><td><code>netstat -tuln<\/code><\/td><td>Show listening ports.<\/td><\/tr><tr><td><code>ss -tuln<\/code><\/td><td>Modern alternative to netstat.<\/td><\/tr><tr><td><code>sudo ufw enable\/disable<\/code><\/td><td>Turn UFW firewall on or off.<\/td><\/tr><tr><td><code>iptables -L<\/code><\/td><td>View current iptables rules.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u2699\ufe0f 5. AUTOMATION &amp; BACKUP<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>crontab -e<\/code><\/td><td>Edit crontab for scheduling tasks.<\/td><\/tr><tr><td><code>mkdir -p \/mnt\/secure-logs<\/code><\/td><td>Create archive directory.<\/td><\/tr><tr><td><code>tar -czf \/mnt\/secure-logs\/logs-YYYY-MM-DD.tar.gz \/var\/log<\/code><\/td><td>Archive logs with compression.<\/td><\/tr><tr><td><code>bash check-secure.sh<\/code><\/td><td>Run a custom security audit script.<\/td><\/tr><tr><td><code>python3 app.py<\/code><\/td><td>Run your Flask dashboard.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udce6 6. PACKAGE &amp; SERVICE MANAGEMENT<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>pip install flask<\/code><\/td><td>Install Flask (Python package).<\/td><\/tr><tr><td><code>sudo apt update &amp;&amp; sudo apt upgrade<\/code><\/td><td>Update system packages.<\/td><\/tr><tr><td><code>systemctl status ssh<\/code><\/td><td>Check SSH service status.<\/td><\/tr><tr><td><code>systemctl restart ssh<\/code><\/td><td>Restart SSH service.<\/td><\/tr><tr><td><code>sudo systemctl enable fail2ban<\/code><\/td><td>Enable fail2ban at boot.<\/td><\/tr><tr><td><code>sudo apt install fail2ban<\/code><\/td><td>Install fail2ban.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83e\udde0 7. CUSTOM \/ OTHER<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>ls -l<\/code><\/td><td>List files with details.<\/td><\/tr><tr><td><code>chmod +x script.sh<\/code><\/td><td>Make script executable.<\/td><\/tr><tr><td><code>.\/script.sh<\/code><\/td><td>Run a shell script in the current directory.<\/td><\/tr><tr><td><code>echo \"hello\"<\/code><\/td><td>Print text to terminal.<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\uddc2\ufe0f CATEGORIES: \u2705 1. SYSTEM MONITORING &amp; INFO Command Description uptime Shows how long the system has been running and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[9],"tags":[25,24,23,26,20],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-tutorial","tag-authentication","tag-fail2ban","tag-linux-command","tag-log","tag-ssh"],"_links":{"self":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":1,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":75,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions\/75"}],"wp:attachment":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}