Linux question of the day
Comments
-
W Stewart Member Posts: 794 ■■■■□□□□□□Guess I was wrong after looking it up. I'll leave it for somebody else to take a shot at it.
-
UnixGuy Mod Posts: 4,570 ModI wrote a short blog post about atime, ctime, and mtime in 2012:
Linux and UNIX: Understanding and modifiying File timestamps | Sahara Geeks -
W Stewart Member Posts: 794 ■■■■□□□□□□Here's one that you'll probably come across early on in your career if you work with linux.
I changed out a motherboard that has an integrated NIC. The network interface now says eth1 every time the system boots instead of eth0.
1. Why does it do that?
2. How can I fix it?
3. Bonus if you can give me at least two alternative ways to fix the problem other than the right way.
You can even do some googling for number 3 if you need to. -
Expect Member Posts: 252 ■■■■□□□□□□70-net-persistent file under udev is responsible for NIC mapping
-
W Stewart Member Posts: 794 ■■■■□□□□□□^ that's pretty much what I was looking for. You could remove the file or just change the mac address in the file to the mac address of the new NIC. Any alternative ways to name the interface?
-
W Stewart Member Posts: 794 ■■■■□□□□□□Just bough a decommissioned server at work and while setting everything up I remembered a question that somebody asked about determining if a device is hardware or software raid. Just wanted to point out that at least with an lsi scsi controller you can run
smartctl -d auto /dev/sda
to determine if it's a raid drive so long as the device supports smart monitoring.
Also to the question I posted above, you can rename an interface by creating the /etc/iftab file or by loading the NIC driver with an alias in the modprobe.conf file such asalias <nic driver> <eth3>
-
W Stewart Member Posts: 794 ■■■■□□□□□□
free -m total used free shared buffers cached Mem: 3832 3388 444 135 177 1557 -/+ buffers/cache: 1653 2179 Swap: 3971 0 3971
Question of the day. My server has 444 megs of ram available for any applications that need it. True of false and why? -
finhack Member Posts: 12 ■□□□□□□□□□false.
it has 2179mb free left for usage. the 444 does not include memory in buffer/cache which linux allocates to programs and releases when new applications rise. -
W Stewart Member Posts: 794 ■■■■□□□□□□Correct, bonus questions that may require some experience with a linux system. What happens when I run out of memory(including memory used for disk caching and buffers) and swap space.
-
paul78 Member Posts: 3,016 ■■■■■■■■■■hmm - I assume the kernel starts to reclaim non-dirty pages but if you are toast then the oom killer starts to kick in.
-
finhack Member Posts: 12 ■□□□□□□□□□I have an interesting one!
how to recover from chmod -x /bin/chmod ? (Real question, no joke) -
W Stewart Member Posts: 794 ■■■■□□□□□□hmm - I assume the kernel starts to reclaim non-dirty pages but if you are toast then the oom killer starts to kick in.
correct -
W Stewart Member Posts: 794 ■■■■□□□□□□I have an interesting one!
how to recover from chmod -x /bin/chmod ? (Real question, no joke)
As root, runsetfacl -m u::rwx; setfacl -m g::rx; setfacl -m o::rx
You could also boot to a live cd and use the chmod command from the live cd to change permissions. -
paul78 Member Posts: 3,016 ■■■■■■■■■■how to recover from chmod -x /bin/chmod ?
@W Stewart - good answer - I wasn't familiar with that command.
What's neat about this question is that I bet there are several ways to do it depending on your background. The 2 solutions that I thought of is not as simple as using setfacl.
I am wondering if there are shell built-ins that can be used to solve this as well.
My own idea was the following:
1) Write your own quick app to turn on the execute bit#include <sys/stat.h> main() { chmod ("/bin/chmod", S_IRWXU|S_IRGRP|S_IXGRP); }
That will turn on the execute bit and then you can use /bin/chmod.
or
2) Call the ELF loader directly on /bin/chmod to fix the execute bit. Something like this:
/lib/ld-linux-x86-64.so.2 /bin/chmod +x /bin/chmod -
finhack Member Posts: 12 ■□□□□□□□□□nice answers,
another one:
What would this command do? (and no, don't try it on production)
:(){ :|: & };: -
W Stewart Member Posts: 794 ■■■■□□□□□□That's a fork bomb. It will run a function called : which calls itself and then pipes the output into another call of itself and runs in the background. It will keep spawning more recursive functions until every instance is killed, the system is rebooted or the system runs out of resources.
-
W Stewart Member Posts: 794 ■■■■□□□□□□Which command can I use on a redhat based system to find the dependencies of a package?
-
finhack Member Posts: 12 ■□□□□□□□□□rpm -qpR
Which command will prevent users from exiting a shell script using ctrl c or ctrl z? -
ChooseLife Member Posts: 941 ■■■■■■■□□□Let's revive this thread, shall we?
Question: How can you tell uptime of a system, without issuing "uptime" command?“You don’t become great by trying to be great. You become great by wanting to do something, and then doing it so hard that you become great in the process.” (c) xkcd #896
GetCertified4Less - discounted vouchers for certs -
Expect Member Posts: 252 ■■■■□□□□□□ChooseLife wrote: »Let's revive this thread, shall we?
Question: How can you tell uptime of a system, without issuing "uptime" command?
top -n 1 | head -1
Question: how can you add timestamps to the history command output? -
ChooseLife Member Posts: 941 ■■■■■■■□□□top -n 1 | head -1“You don’t become great by trying to be great. You become great by wanting to do something, and then doing it so hard that you become great in the process.” (c) xkcd #896
GetCertified4Less - discounted vouchers for certs -
hiddenknight821 Member Posts: 1,209 ■■■■■■□□□□Question: how can you add timestamps to the history command output?
GREAT QUESTION! I kept the honor code, and try not to refer to Google or the like, and I was able to figure out the answer after spending an hour on this. As always, the answer is in the man page of bash since history is bash built-in command. I had to change the HISTTIMEFORMAT variable. Yet, I didn't know how to manipulate it until the man referred me to the third section of strftime man page, which helped me arrive at the answer.
I like the format below. It's more readable:
%D' '%I:%M:%S' '%P' '%Z': ' -
Expect Member Posts: 252 ■■■■□□□□□□ChooseLife wrote: »How else? I am not looking for a command that readily prints the uptime (i.e. no "uptime", no "top, no "w", etc)
e.g.:dolev@ubuntu:~$ stat /proc/uptime File: ‘/proc/uptime’ Size: 0 Blocks: 0 IO Block: 1024 regular empty file Device: 3h/3d Inode: 4026532042 Links: 1 Access: (0444/-r--r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2015-03-10 06:02:04.864524011 +0200 Modify: 2015-03-10 06:02:04.864524011 +0200 Change: 2015-03-10 06:02:04.864524011 +0200 Birth: -
-
Expect Member Posts: 252 ■■■■□□□□□□hiddenknight821 wrote: »GREAT QUESTION! I kept the honor code, and try not to refer to Google or the like, and I was able to figure out the answer after spending an hour on this. As always, the answer is in the man page of bash since history is bash built-in command. I had to change the HISTTIMEFORMAT variable. Yet, I didn't know how to manipulate it until the man referred me to the third section of strftime man page, which helped me arrive at the answer.
I like the format below. It's more readable:
%D' '%I:%M:%S' '%P' '%Z': '
good work,
Question: how can you create an iptables firewall rule related to an already established connection? -
ChooseLife Member Posts: 941 ■■■■■■■□□□files under /proc are created on boot so their creation date is the same as the uptime of the system
e.g.:dolev@ubuntu:~$ stat /proc/uptime File: ‘/proc/uptime’ Size: 0 Blocks: 0 IO Block: 1024 regular empty file Device: 3h/3d Inode: 4026532042 Links: 1 Access: (0444/-r--r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2015-03-10 06:02:04.864524011 +0200 Modify: 2015-03-10 06:02:04.864524011 +0200 Change: 2015-03-10 06:02:04.864524011 +0200 Birth: -
ps eo lstart -p 1
but this is same“You don’t become great by trying to be great. You become great by wanting to do something, and then doing it so hard that you become great in the process.” (c) xkcd #896
GetCertified4Less - discounted vouchers for certs -
Expect Member Posts: 252 ■■■■□□□□□□ChooseLife wrote: »I will take it I was looking for something along the lines of
ps eo lstart -p 1
but this is same -
W Stewart Member Posts: 794 ■■■■□□□□□□Haven't been hear in awhile. What does the D status flag in the top command mean?